Hi,
I'm working on the admin section of a website i'm building, and I'm trying to build some queries that get stats of record changes.
Basically I want to query how many records exist that will fall within certain date ranges.
so far, if I want to find records where a datefield has a value within the last month I use something like this
WHERE last_login_date > DATEADD(month,-1,GETDATE())
I'm still trying to figure out the best way to select other dates.
I need the following ranges
within the current day. even if its 1am on tuesday and the day is only 1 hour old, only stuff that matches today/tuesday
within the past hour
within the past 24 hours
within the past week
past month
past year
is dateadd the best function to use?
I'm working on the admin section of a website i'm building, and I'm trying to build some queries that get stats of record changes.
Basically I want to query how many records exist that will fall within certain date ranges.
so far, if I want to find records where a datefield has a value within the last month I use something like this
WHERE last_login_date > DATEADD(month,-1,GETDATE())
I'm still trying to figure out the best way to select other dates.
I need the following ranges
within the current day. even if its 1am on tuesday and the day is only 1 hour old, only stuff that matches today/tuesday
within the past hour
within the past 24 hours
within the past week
past month
past year
is dateadd the best function to use?
