none
Default parameter dates expression help

    Question

  • I'm not sure what to put for the expression for a few default date parameters. I need three different ones. 

    1. 7/1/current year

    2. 7/1/previous year

    3. current month/current day/last year (i.e. it is 7/22/13 today. I need 7/22/12 to appear)


    ipainter

    Monday, July 22, 2013 8:53 PM

Answers

  • Hi, A question about your requirement.

    1. 7/1/current year -- Should it be Current Month/1/Current Year ? If Yes find expression below

    =Format(Today.AddDays(1 - Today.Day), "MM/dd/yyyy")

    2. 7/1/previous year -- Should it be Current Month/1/Previous Year ? If Yes find expression below

    =Format(Today.AddDays(1 - Today.Day).AddYears(-1), "MM/dd/yyyy")
    3.
    =Format(Today.AddYears(-1), "MM/dd/yyyy")


    Ione



    Monday, July 22, 2013 9:06 PM
  • 1.

    ="7/1/" & Today.Year

    2.

    ="7/1/" & (DatePart(DateInterval.Year, Today)-1)

    This works in SSRS 2008 R2, not sure which version is yours.

    Hope this helps.


    Ione

    • Marked as answer by hizic Wednesday, July 24, 2013 9:13 PM
    Wednesday, July 24, 2013 8:25 PM
  • Use the Expressions below.

    =CDate("7/1/" & Today.Year)
    
    =CDate("7/1/" & (DatePart(DateInterval.Year, Today)-1))

    Hope this helps.

    Ione

    • Marked as answer by hizic Thursday, September 19, 2013 5:25 PM
    Tuesday, September 17, 2013 10:10 PM
  • You should re-write the expression as below.

    =CDate(Format(Today.AddYears(-1), "MM/dd/yyyy")) 
    
    =CDate(Today.AddYears(-1))

    Hope this helps.

    Ione

    • Marked as answer by hizic Thursday, September 19, 2013 5:25 PM
    Thursday, September 19, 2013 5:06 PM

All replies

  • Hi, A question about your requirement.

    1. 7/1/current year -- Should it be Current Month/1/Current Year ? If Yes find expression below

    =Format(Today.AddDays(1 - Today.Day), "MM/dd/yyyy")

    2. 7/1/previous year -- Should it be Current Month/1/Previous Year ? If Yes find expression below

    =Format(Today.AddDays(1 - Today.Day).AddYears(-1), "MM/dd/yyyy")
    3.
    =Format(Today.AddYears(-1), "MM/dd/yyyy")


    Ione



    Monday, July 22, 2013 9:06 PM
  • For 1 and 2...

    I need it to be as specified in the original question

    1. July/1/current year

    2. July/1/previous year

    Thank you for your help!


    ipainter


    • Edited by hizic Wednesday, July 24, 2013 7:05 PM fixed
    Wednesday, July 24, 2013 7:04 PM
  • 1.

    ="7/1/" & Today.Year

    2.

    ="7/1/" & (DatePart(DateInterval.Year, Today)-1)

    This works in SSRS 2008 R2, not sure which version is yours.

    Hope this helps.


    Ione

    • Marked as answer by hizic Wednesday, July 24, 2013 9:13 PM
    Wednesday, July 24, 2013 8:25 PM
  • I know it's been a while! I'm just getting around to this. 

    I tried ="7/1" & Today.Year and got the following error:


    ipainter

    Tuesday, September 17, 2013 8:29 PM
  • What is the DataType that you are using?

    Ione

    • Marked as answer by hizic Tuesday, September 17, 2013 9:47 PM
    • Unmarked as answer by hizic Tuesday, September 17, 2013 9:52 PM
    Tuesday, September 17, 2013 9:04 PM
  • Actually...wait...

    After changing it to text my report won't run now. I get this error. 


    ipainter

    Tuesday, September 17, 2013 9:53 PM
  • Use the Expressions below.

    =CDate("7/1/" & Today.Year)
    
    =CDate("7/1/" & (DatePart(DateInterval.Year, Today)-1))

    Hope this helps.

    Ione

    • Marked as answer by hizic Thursday, September 19, 2013 5:25 PM
    Tuesday, September 17, 2013 10:10 PM
  • Cool! It works! Thank you :)

    How would I get #3 to work? You had suggested earlier that I do:

    =Format(Today.AddYears(-1), "MM/dd/yyyy")

    But that doesn't appear to be working either. It tells me the following:


    ipainter

    Thursday, September 19, 2013 4:17 PM
  • You should re-write the expression as below.

    =CDate(Format(Today.AddYears(-1), "MM/dd/yyyy")) 
    
    =CDate(Today.AddYears(-1))

    Hope this helps.

    Ione

    • Marked as answer by hizic Thursday, September 19, 2013 5:25 PM
    Thursday, September 19, 2013 5:06 PM
  • Perfect! Thank you soooo much for your help!

    ipainter

    Thursday, September 19, 2013 5:26 PM