Hacktastic
Technical User
Trying to make some groupings on a date field in a query like this :
case when (CAST(FLOOR(CAST(date AS FLOAT)) AS DATETIME)) >= getdate()-8 then '7 days'
when (CAST(FLOOR(CAST(date AS FLOAT)) AS DATETIME)) >= getdate()-15 then '14 days'
when (CAST(FLOOR(CAST(date AS FLOAT)) AS DATETIME)) >= getdate()-31 then '30 days'
else '45 days' end
but it doesn't produce the results i need,
namely i want to have a selection of 7 days ago, 14 days ago, 30 days ago and 45 days ago.
so the 14 days ago population should also include the folks from 7 days ago...
This is going to be used as a filter once i pass the data into excel.
Thanks!
case when (CAST(FLOOR(CAST(date AS FLOAT)) AS DATETIME)) >= getdate()-8 then '7 days'
when (CAST(FLOOR(CAST(date AS FLOAT)) AS DATETIME)) >= getdate()-15 then '14 days'
when (CAST(FLOOR(CAST(date AS FLOAT)) AS DATETIME)) >= getdate()-31 then '30 days'
else '45 days' end
but it doesn't produce the results i need,
namely i want to have a selection of 7 days ago, 14 days ago, 30 days ago and 45 days ago.
so the 14 days ago population should also include the folks from 7 days ago...
This is going to be used as a filter once i pass the data into excel.
Thanks!