Hi,
I have a script that need to be run automatically in the first day of each month and get the previous 3 month data. How can I write a SQL expression to set the time range? For example, if the script runs on 5/1/2013, the data should include 02/01/2013 to 04/30/2013. Now I am doing it this way:
pp.timestamp BETWEEN DATEADD(DAY,-90,GETDATE()) AND DATEADD(DAY,-1,GETDATE()) )
But the problem is that it won’t be accurate when the month has 31 days or 28 days.
How can I make it more accurate?
Thank you for any ideas and suggestions!!!
I have a script that need to be run automatically in the first day of each month and get the previous 3 month data. How can I write a SQL expression to set the time range? For example, if the script runs on 5/1/2013, the data should include 02/01/2013 to 04/30/2013. Now I am doing it this way:
pp.timestamp BETWEEN DATEADD(DAY,-90,GETDATE()) AND DATEADD(DAY,-1,GETDATE()) )
But the problem is that it won’t be accurate when the month has 31 days or 28 days.
How can I make it more accurate?
Thank you for any ideas and suggestions!!!