August 2, 2012 at 9:22 am
Hi,
I am trying to update @start and @end date in my report with the coding logic below at report level , and the commented out are my attempt at these. I need help at 2-3 places in the IIF statement. Any ideas will be appreciated.
Thank you !!
****@start***************************************************************
if (todays date = first day of the current month
----Today()=DateSerial(Year(Today()), Month(Today()),1)
OR
todays date = second day of current month )
----------------???
then
first day of last month
---=DateAdd("m", -1, DateSerial(Year(Now()), Month(Now()), 1))
else
first day of current month
-----=DateSerial(Year(Today()), Month(Today()),1)
***************@END****************************************
if todays date = first day of current month
----Today()=DateSerial(Year(Today()), Month(Today()),1)
OR todays date = second day of current month
---------------- ???
then
last day of last month
--- ???
else
yesterday
-------=dateadd("d", -1, Today())
August 2, 2012 at 9:38 am
This should answer all those questions and more. http://www.sqlservercentral.com/blogs/lynnpettis/2009/03/25/some-common-date-routines/[/url]
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
August 7, 2012 at 6:38 am
Thank you for your help !!
August 7, 2012 at 7:52 am
You're welcome. Hope that helped.
_______________________________________________________________
Need help? Help us help you.
Read the article at http://www.sqlservercentral.com/articles/Best+Practices/61537/ for best practices on asking questions.
Need to split a string? Try Jeff Modens splitter http://www.sqlservercentral.com/articles/Tally+Table/72993/.
Cross Tabs and Pivots, Part 1 – Converting Rows to Columns - http://www.sqlservercentral.com/articles/T-SQL/63681/
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs - http://www.sqlservercentral.com/articles/Crosstab/65048/
Understanding and Using APPLY (Part 1) - http://www.sqlservercentral.com/articles/APPLY/69953/
Understanding and Using APPLY (Part 2) - http://www.sqlservercentral.com/articles/APPLY/69954/
Viewing 4 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply