last month and year has default value

  • Need to set default value for a parameter has last month and same year (e.g 08-2017)

    Thanks in advance

  • GA_SQL - Friday, September 15, 2017 7:57 AM

    Need to set default value for a parameter has last month and same year (e.g 08-2017)

    Thanks in advance

    Are you looking for an expression, T-SQL? What have you tried?

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • In SSRS while setting default value for parameter i am trying to set default value for a parameter has last month and same year (e.g 08-2017)

  • GA_SQL - Friday, September 15, 2017 8:24 AM

    In SSRS while setting default value for parameter i am trying to set default value for a parameter has last month and same year (e.g 08-2017)

    Ok, but that doesn't answer any of my prior questions, that's just a repeat of your requirements. 🙂 See my quoted post below.

    Thom A - Friday, September 15, 2017 8:02 AM

    Are you looking for an expression, T-SQL? What have you tried?

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • I have one SSRS report, text parameter which is in 09-2017 (drop down of all the months in year) format , for default parameter i need load last month load like 08-2017

  • GA_SQL - Friday, September 15, 2017 9:18 AM

    I have one SSRS report, text parameter which is in 09-2017 (drop down of all the months in year) format , for default parameter i need load last month load like 08-2017

    You're just asking the question again, and not answer my questions:

    1. Do you want the answer in:

    1. T-SQL?
    2. SSRS Expression?
  • What have you tried so far?

Thom~

Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
Larnu.uk

  • Refer to this attachment

  • i need solution has SSRS expression
    I tried some like this
    =DateAdd("m", -2, DateSerial(Year(Now()), Month(Now()), 1))

    later i found this parameter type is text  as attached

  • GA_SQL - Friday, September 15, 2017 9:36 AM

    i need solution has SSRS expression
    I tried some like this
    =DateAdd("m", -2, DateSerial(Year(Now()), Month(Now()), 1))

    later i found this parameter type is text  as attached

    Ok, now we're getting somewhere :).

    When you say you want the date, are you actually looking for a date value, or a text value with the value "08-2017"? If you want a date with for the start of the previous month, you'll need to change the datatype of your paramter to date. Then you can use:
    'Today, this would return 2017-08-01
    =Dateadd("M", DateDiff("M", "01/01/2000",Today())-1,"01/01/2000")

    If you want the text format, then you'll want for add a format to it:
    'today this would return "08-2017"
    =Format(Dateadd("M", DateDiff("M", "01/01/2000",Today())-1,"01/01/2000"),"MM-yyyy")

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk

  • Viewing 9 posts - 1 through 8 (of 8 total)

    You must be logged in to reply to this topic. Login to reply