robsuttonjr
MIS
I need to dynamically query past 8 weeks and current week based on a given date. I can't use the week function since I am on sql
So if I say in where clause for example:
EVENTDATE between cast('03/06/17' as datetime) and cast('03/06/17' as datetime) + 6
This will give me current week based on a static given date.
Now I need to go back 8 weeks or 56 days. Currently I have created 8 other union queries using subtraction to get what I need but this is very cumbersome to maintain and very slow.
Any examples of how someone has been able to create a query which will dynamically create an 8 week past and 1 week forward query using aggregates would help greatly.
Regards,
Rob
So if I say in where clause for example:
EVENTDATE between cast('03/06/17' as datetime) and cast('03/06/17' as datetime) + 6
This will give me current week based on a static given date.
Now I need to go back 8 weeks or 56 days. Currently I have created 8 other union queries using subtraction to get what I need but this is very cumbersome to maintain and very slow.
Any examples of how someone has been able to create a query which will dynamically create an 8 week past and 1 week forward query using aggregates would help greatly.
Regards,
Rob