I am writing a SQL query in Aginity through Amazon Redshift to extract the last 7 days of data. The Date
column which I am calling is in the variable type:
DATE
An example output is this:
5/30/2017 0:00
When I call the below function, does it matter what time of day I run this query or will it always take the full day's worth of data?
WHERE Date >= DATEADD(day,-7, GETDATE())
Yes, this includes the current time component when subtracting 7 days. To get rid of that, convert to a date:
WHERE Date >= CAST(DATEADD(day, -7, GETDATE()) as DATE)