SSRS 2008 R2 - default date from and date to values (dd/MM/yyyy)?
Hi, I have SSRS 2008 R2 visuaul studio project. In my report I have parameters like DATEFROM and DATETO (datetime type). Can I have default values expressions for: 1) DATEFROM : First date of last month and DATETO : Last date of last month in dd/MM/yyyy format (i.e. 25/12/2010) 2) DATEFROM : First date of current month and DATETO : Last date of current month in dd/MM/yyyy format (i.e. 25/12/2010) 3) DATEFROM : Yesterday's date and DATETO : tomorrow's date in dd/MM/yyyy format (i.e. 25/12/2010) Any SSRS 2008 R2 expressions for above three default dates? Thank You.
April 7th, 2011 2:23am

=DateAdd("m", -1, DateSerial(Year(Now()), Month(Now()), 1)) This expression will give you the first day of the PREVIOUS monthBest Regards, Uri Dimant SQL Server MVP http://dimantdatabasesolutions.blogspot.com/ http://sqlblog.com/blogs/uri_dimant/
Free Windows Admin Tool Kit Click here and download it now
April 7th, 2011 2:28am

Do you have expression for others datefrom / dateeto as I mentioned above?
April 7th, 2011 2:40am

I have some for week but you can make it for month http://hardik-bhavsar.blogspot.com/2011/03/default-values-for-date-parameters-in.html
Free Windows Admin Tool Kit Click here and download it now
April 7th, 2011 3:39am

Hi, See if this helps First Date of last month: =Format(DateAdd("m", -1, DateSerial(Year(Now()), Month(Now()), 1)),"dd/MM/yyyy") Last date of last month: =Format(DateAdd("d", -1, DateSerial(Year(Now()), Month(Now()), 1)),"dd/MM/yyyy") First date of current month: =Format(DateSerial(Year(Now()), Month(Now()), 1),"dd/MM/yyyy") Last date of current month: =Format(DateAdd("d",-1,(DateAdd("m", 1, DateSerial(Year(Now()), Month(Now()), 1)))),"dd/MM/yyyy") Yesterday's date : =Format(DateAdd("d", -1, now()),"dd/MM/yyyy") tomorrow's date : =Format(DateAdd("d", 1, now()),"dd/MM/yyyy") - Chintak (My Blog)
April 7th, 2011 5:24am

Hi there, I tried your all expressions in my Visual Studio 2008 but its give me error like "The Property 'DefaultValue' of report parameter 'DATEFROM' doesn't have the expected type. DATEFROM cast is datetime. Any idea how to resolve this error? Thanks. ??
Free Windows Admin Tool Kit Click here and download it now
April 7th, 2011 10:05pm

Hi KM IT, The error is caused by using the Format function. Please try to remove the format part in the expressions posted by Chintak and test again: § =DateAdd("m", -1, DateSerial(Year(Now()), Month(Now()), 1)) § =DateAdd("d", -1, DateSerial(Year(Now()), Month(Now()), 1)) § =DateSerial(Year(Now()), Month(Now()), 1) § =DateAdd("d",-1,(DateAdd("m", 1, DateSerial(Year(Now()), Month(Now()), 1)))) § =DateAdd("d", -1, now()) § =DateAdd("d", 1, now()) Regarding to the date format in report parameter, please refer to the answer it the thread http://social.msdn.microsoft.com/Forums/en-US/sqlreportingservices/thread/50e8dccd-093d-4f3c-84a9-c4f39a6c36ef/ If anything is unclear, please feel free to ask. Thanks, Tony Chain Tony Chain [MSFT] MSDN Community Support | Feedback to us Get or Request Code Sample from Microsoft Please remember to mark the replies as answers if they help and unmark them if they provide no help.
April 7th, 2011 11:21pm

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

Other recent topics Other recent topics