I have a table in my database. This table is called Order. It has a structure like this
- ID
- CustomerID
- OrderDate
- Quantity
- Price
I need to get all of the orders for the past 2 weeks. How do I do that? I don’t understand how to work with dates in this manner in SQL.
Thank you!
You could incorporate something like this into your
WHEREclause:(i.e OrderDate is more recent than today minus 14 days.)
[I don’t have access to SQL Server here so I can’t check it – but it might work :)]
Edit: Depending on the exact datatype of OrderDate, I’m not sure what will happen in cases where you have e.g. an order half way through the day two weeks ago, so you might want to check what happens.