Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 Development Tools
 Reporting Services Development
 formatting datefield to mmm - yy

Author  Topic 

latingntlman
Yak Posting Veteran

96 Posts

Posted - 2008-07-17 : 16:40:52
I've passed a date field from s stored proc but I'm trying to format it. i.e. I'm trying to format/convert the value 1/31/2008 in datefield to display as January - 2008, or Jan - 2008, but I just can't figure out what expression/syntax I need to use. I also have two date parameters and I'm trying to include a textbox in the header section which shows the begindate and enddate parms as mmm - yy or mmmmm - yy, but I can't figure that out either.

I looked up MSDN library but couldn't find the relevant expression/syntax.

Any help is greatly appreciated.

John

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-17 : 16:47:58
[code]SELECT STUFF(CONVERT(CHAR(11), GETDATE(), 100), 5, 2, '-')[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-17 : 16:48:50
[code]SELECT DATENAME(MONTH, GETDATE()) + ' - ' + DATENAME(YEAR, GETDATE())[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

latingntlman
Yak Posting Veteran

96 Posts

Posted - 2008-07-17 : 16:53:34
Does this syntax work in Reporting Services? It looks like it would work with SQL.
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-07-17 : 16:58:09
You can always FORMAT the date in Reporting Services.



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-07-18 : 02:42:31
In my example i have used the ExecutionTime.
Replace this with your Datevalue.

Textbox Properties --> Format --> Format code: =MonthName(Month(Globals!ExecutionTime)) & " - " & Year(Globals!ExecutionTime)

Greetings
Webfred

There are 10 types of people in the world: Those who understand binary, and those who don't...
Go to Top of Page

latingntlman
Yak Posting Veteran

96 Posts

Posted - 2008-07-18 : 09:41:54
Thx Webfred, that's exactly what I was looking for. Unfortunately, I haven't found a source for Expression syntax for Reporting Services, like for example SQL, or Access, or Excel, etc.
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-07-18 : 09:58:48
quote:

Thx Webfred, that's exactly what I was looking for. Unfortunately, I haven't found a source for Expression syntax for Reporting Services, like for example SQL, or Access, or Excel, etc.



Right-click on the textbox. Choose Properties. Click on the "Format" tab. Enter a Format Code. Done.

Remember that you use capital M's when formatting month's, not lowercase. So, if you want Jan 07 you would use "MMM yy".

Don't use hard-coded expressions or format via conversions in T-SQL if you can just format a textbox using a format code.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2008-07-18 : 09:59:31
quote:
Originally posted by Peso

You can always FORMAT the date in Reporting Services.



Let me just tweak that for you ...

quote:


You can should always FORMAT the date in Reporting Services.



- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -