Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Default dates? Expand / Collapse
Author
Message
Posted Thursday, August 2, 2012 9:22 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Sunday, December 14, 2014 4:20 AM
Points: 160, Visits: 342

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())

Post #1339283
Posted Thursday, August 2, 2012 9:38 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 2:05 PM
Points: 13,327, Visits: 12,820
This should answer all those questions and more. http://www.sqlservercentral.com/blogs/lynnpettis/2009/03/25/some-common-date-routines/

_______________________________________________________________

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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1339301
Posted Tuesday, August 7, 2012 6:38 AM


SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Sunday, December 14, 2014 4:20 AM
Points: 160, Visits: 342
Thank you for your help !!
Post #1341195
Posted Tuesday, August 7, 2012 7:52 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: 2 days ago @ 2:05 PM
Points: 13,327, Visits: 12,820
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 Moden's splitter.

Cross Tabs and Pivots, Part 1 – Converting Rows to Columns
Cross Tabs and Pivots, Part 2 - Dynamic Cross Tabs
Understanding and Using APPLY (Part 1)
Understanding and Using APPLY (Part 2)
Post #1341276
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse