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


Formatting Dates


Formatting Dates

Author
Message
gabriel.defigueiredo
gabriel.defigueiredo
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
Points: 25 Visits: 144
Refers to issues with SQL Server 2005 Reporting Services (I am not sure if this occurs in the 2008 reincarnation)

Requirement: I would like to display dates in dd-MMM-yyyy format.

Problem: Column used for display in a SSRS report is a datetime. I right-clicked on the relevant text box, selected Properties and then the Format tab, clicked fx and typed the expression
=Format (<datetime field from dataset>, "dd-MMM-yyyy").

The above gives months as "Jan", "eb", "3ar", "Apr", "5a10", "Jun", "Jul", "AuA.D.", "Sep", "OcP", "Nov", "Dec".

Cure: DO not use the FORMAT tab of Text box Properties. On right-click of the Text box, click on Expression instead, and enter the expression here, as in:
=format(Fields!LastBackupStart.Value, "dd-MMM-yyyy HH:mm:ss")

Seems to work OK. Hope this helps anyone tearing their hair out ....
Peter Brinkhaus
Peter Brinkhaus
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2015 Visits: 7365
You are using the wrong expression for the format. Given a date of 2/3/2009, your expression

=Format (<datetime field from dataset>, "dd-MMM-yyyy").

evaluates to "3-Feb-2009" which is then used to format the date, which results in 03-2eb-2009.

Simply enter dd-MMM-yyyy in the format textbox or use expression ="dd-MMM-yyyy" will fix the problem.

Peter
gabriel.defigueiredo
gabriel.defigueiredo
SSC Rookie
SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)SSC Rookie (25 reputation)

Group: General Forum Members
Points: 25 Visits: 144
Thank you for that - you've pointed me in the right direction :-)
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