Weekly data to ssrs
The following article deals with date range specifications: http://www.sqlusa.com/bestpractices2008/between-dates/ Kalman Toth, SQL Server & Business Intelligence Training; SQL 2008 Grand Slam
June 30th, 2011 7:41pm

I have a report, that's updated weekly, for orders placed duriing the week. I need a select statement to pull this data from the current date to 7 days prior ( the week prior). The report is meant to be a "subscription" and emailed to the user on Monday morning. 1. locations are closed on the weekend so no data is posted after Friday's 2. the select statement is pulling information from one table (kind of a histroy table). Any help would be appreciated.Never enough time to do the job right, but always enough time to do the job over.
Free Windows Admin Tool Kit Click here and download it now
July 2nd, 2011 11:41am

select * from table where orderdate between dateadd(wk, datediff(wk, 0, getdate()) - 1, 0) and dateadd(wk, datediff(wk, 0, getdate()) - 1, 0) + 4
July 2nd, 2011 12:15pm

The following article deals with date range specifications: http://www.sqlusa.com/bestpractices2008/between-dates/ Kalman Toth, SQL Server & Business Intelligence Training; SQL 2008 Grand Slam
Free Windows Admin Tool Kit Click here and download it now
July 2nd, 2011 12:53pm

that is the simplest I have tried. I am receiving the error Msg 8115, Level 16, State 2, Line 1 Arithmetic overflow error converting expression to data type datetime. Our datatables store the date as yyyymmdd. Any suggestions on how to reformat the date? Thanks for the fast response. Never enough time to do the job right, but always enough time to do the job over.
July 2nd, 2011 5:05pm

Try SELECT CAST(CAST(DateField AS VARCHAR(8)) AS DATETIME) to format your date column then use this in the above expression(replace getdate() with this expression)
Free Windows Admin Tool Kit Click here and download it now
July 2nd, 2011 5:37pm

To convert date you can use: SELECT CONVERT(DATE,'20111231',112) and the wrap it in dateadd().
July 3rd, 2011 1:39am

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics