SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


last month and year has default value


last month and year has default value

Author
Message
GA_SQL
GA_SQL
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1520 Visits: 563
Need to set default value for a parameter has last month and same year (e.g 08-2017)

Thanks in advance
Thom A
Thom A
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45603 Visits: 15467
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 :-P

Please always remember to encapsulate your code in IFCode Markup. For example [code=sql] [/code].
Click here to read Jeffs Guide on how to post SQL questions, and get swift and helpful answers from the community
GA_SQL
GA_SQL
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1520 Visits: 563
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)
Thom A
Thom A
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45603 Visits: 15467
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. Smile 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 :-P

Please always remember to encapsulate your code in IFCode Markup. For example [code=sql] [/code].
Click here to read Jeffs Guide on how to post SQL questions, and get swift and helpful answers from the community
GA_SQL
GA_SQL
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1520 Visits: 563
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
Thom A
Thom A
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45603 Visits: 15467
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?
  2. What have you tried so far?



Thom~
Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does :-P

Please always remember to encapsulate your code in IFCode Markup. For example [code=sql] [/code].
Click here to read Jeffs Guide on how to post SQL questions, and get swift and helpful answers from the community
GA_SQL
GA_SQL
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1520 Visits: 563
Refer to this attachment
Attachments
1.jpg (7 views, 66.00 KB)
GA_SQL
GA_SQL
SSCommitted
SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)SSCommitted (1.5K reputation)

Group: General Forum Members
Points: 1520 Visits: 563
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
Thom A
Thom A
SSC-Forever
SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)SSC-Forever (45K reputation)

Group: General Forum Members
Points: 45603 Visits: 15467
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 Smile.

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 :-P

Please always remember to encapsulate your code in IFCode Markup. For example [code=sql] [/code].
Click here to read Jeffs Guide on how to post SQL questions, and get swift and helpful answers from the community
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum







































































































































































SQLServerCentral


Search