建议的答复 Report Builder 3 SQL 2008R2

  • Thursday, January 31, 2013 2:28 AM
     
     

    I have a report that looks at business activity in the previous calendar month.

    The report has a subscription to run on the 1st day of the month.

    Can someone assist in advising the scripting for select records with a date in the last calendar month, eg, parameter, filter etc.

    Many thanks

All Replies

  • Thursday, January 31, 2013 2:46 AM
     
     Proposed Has Code
    SELECT	DATEADD(MONTH, DATEDIFF(MONTH, '19000201', GETDATE()), '19000101') AS FirstDayLastYear,
    	DATEADD(MONTH, DATEDIFF(MONTH, '19000101', GETDATE()), '18991231') AS LastDayLastYear

    something of this sort in where caluse

    Regards,Eshwar


    Please don't forget to Marked as Answer if my post solved your problem and use Vote As Helpful if a post was useful. It will helpful to other users.

  • Friday, February 01, 2013 8:42 AM
    Moderator
     
     

    Hi Gratrw,

    From your description, you want to subscribe the last month data on the 1st day of a month, right? If in this case, Eswararao's solution is exaclty right. Just adding to Eswararao's anwser, you can refer to the link below to see DATEADD function.
    http://msdn.microsoft.com/en-us/library/aa337194(v=sql.90).aspx

    If you have any questions, please feel free to ask.

    Regards,


    Charlie Liao
    TechNet Community Support

    • Marked As Answer by GaryRW Tuesday, February 05, 2013 10:48 PM
    • Unmarked As Answer by GaryRW Friday, March 01, 2013 3:58 AM
    •  
  • Wednesday, February 13, 2013 12:35 AM
     
     

    Hi Charlie,

    Could you kindly supply me with the syntax for setting the dates so that each new month the report will look back at the previous month.

    For example, I want to set the report to run on the 1st day of each month, via a 'Subscription' looking at all activity in the previous calendar month referencing a transaction date field.

    Many thanks,

    Gary