x
login about faq Site discussion (meta-askssc)

Formatting a parameter

What formula should I use to have a SSRS parameter show the first day of the current month as its default value in the format dd/MMM/yyy eg 01/Jan/2010?

I am currently using =cdate(format("short date",DateAdd("d",(Day(now)*-1)+1,Now))) which returns it as 01/01/2010 17:11:16 I have also tried =cdate(format("dd/MMM/yyyy",DateAdd("d",(Day(now)*-1)+1,Now))) with no better effect. I am also going to need a parameter for the last day of the month but its the formatting that is the problem at the moment.

I could easily get this with a call to the SQL Server but it seems a waste.

more ▼

asked Jan 25 '10 at 02:16 PM in Default

Fatherjack gravatar image

Fatherjack ♦♦
38.8k 55 69 104

(comments are locked)
10|1200 characters needed characters left

2 answers: sort newest

Actually ended using =cdate(DateAdd("d",(Day(now)*-1)+1,Now).ToString("dd/MMM/yyyy")) for the first day of this month as the parameter has to be of date type. Many thanks to MisterMagoo for the nudge in the right direction using .ToString("dd/MMM/yyyy")

more ▼

answered Jan 26 '10 at 05:39 AM

Fatherjack gravatar image

Fatherjack ♦♦
38.8k 55 69 104

(comments are locked)
10|1200 characters needed characters left

Try this:

=dateadd(
	"d",
	1,
	dateadd(
			"m",
			datediff("m","31 dec 1899", Globals!ExecutionTime)-1,
			DateValue("31 dec 1899")
			)
	).ToString("dd/MMM/yyyy")
more ▼

answered Jan 25 '10 at 04:00 PM

Mister Magoo gravatar image

Mister Magoo
420 3

+1 - thanks for the .ToString("dd/MMM/yyyy")

Jan 26 '10 at 05:39 AM Fatherjack ♦♦
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments



Facebook logo Follow Ask SSC on Facebook
Find Ask SSC on Google+
linkedin logo Find us on LinkedIn

Topics:

x1834
x486
x32

asked: Jan 25 '10 at 02:16 PM

Seen: 1182 times

Last Updated: Jan 25 '10 at 06:48 PM

Copyright © 2002-2012 Simple Talk Publishing. All Rights Reserved. If you have any queries, please contact the site administrators.
Ask SQL Server Central is a community service provided by Red Gate.