Hi There,

Thank You for visiting my blog. I have moved this blog to a new address http://dattatreysindol.com/. Please visit the blog at new address and re-point your feeds to the new address to continue to receive regular updates.
Thanks,
Dattatrey Sindol (Datta)

Datta's Ramblings on Business Intelligence 'N' Life

Formatting Date and Time in SQL Server Reporting Services (SSRS) Reports

» 9 Feb 2011 | | |

Formatting Date and Time in SQL Server Reporting Services (SSRS) is a very common need. And in some cases customers look for a very specific format, so it is important to understand the basic components of date and time formats.

SSRS offers many in-built Date and Time formats. Below are some of the in-built Date formats available in SSRS:


Below are some of the in-built Time formats available in SSRS:


However, sometimes customers need a different format which is not available using SSRS UI (In-built). For example let us say that customers want the Date and Time to be formatted as shown below.

09-Feb-2011 10:47:40 PM (GMT+05:30)

To address this kind of requirements, we need to understand the various formatting codes/strings that are supported in SSRS. Below is a list of various format codes available in SSRS.

Format CodeDescriptionExample
dSingle Digit Date Format9
ddDouble Digit Date Format09
ddd or ddddFull Day NameWednesday
MSingle Digit Month Format2
MMDouble Digit Month Format02
MMMThree Character Month NameFeb
MMMMFull Month NameFebruary
yyDouble Digit Year Format11
yyyyFour Digit Year Format2011
HSingle Digit "24 Hour" Hour Format6
HHDouble Digit "24 Hour" Hour Format06
mSingle Digit Minute Format9
mmDouble Digit Minute Format09
sSingle Digit Second Format4
ssDouble Digit Second Format04
ttante meridian (AM)/post meridian (PM) part of TimePM
zzzTime Zone Offset w.r.t. GMT+05:30

With reference to the format codes given in the above table, please note the following:
  • Format codes are case-sensitive in most cases. Like m represents Minutes and M represents Month.
  • Format codes can be combined using some meaningful characters like "-", "," etc. to customize the Date and Time display.
Below is a sample report which displays various combinations of Date and Time values.


The .rdl file for the demo report in the above screenshot can be downloaded from my SkyDrive here.

Note: This demo is based on SQL Server 2008 R2 Reporting Services.

Following are some of the most popular articles related to formatting in SSRS:
As always, please leave your comments if you like this article :-)

Readers Feedback:
Did you like this article?
If Yes, then please share it:
Did you like my blog?
If Yes, then please help spread the word by sharing this blog with your colleagues, friends, & anyone else in the MSBI Space: Like us on Facebook , Follow us on Twitter .

6 comments:

Anonymous,  February 22, 2012  

Good post! Saved my day!

Anonymous,  March 20, 2012  

One of the most commonly used formats doesn't seem to work anymore on 2008 R2.
The ISO standard of --> "yyyy-MM-dd HH:mm:ss"

Curious if I'm the only one who has experienced or noticed this....

Anonymous,  March 20, 2012  

Nevermind. ISO standard works just fine.

Anonymous,  June 12, 2012  

How would I display this 2012-05-01 01:14:40.373, is there no way to display the microseconds. We use this for transactions, so I really need them as well as when exporting to csv.

Any ideas

Dattatrey Sindol (Datta),  June 12, 2012  

Hi There,
Please use the following expression to display the date/time up to millisecond level.
Format(Fields!Col1.Value, "dd-MMM-yyyy HH:mm:ss.fff")

Hope that helps!

Best Regards,
Dattatrey Sindol (Datta)
http://dattatreysindol.com

Anonymous,  June 20, 2012  

Thanks for this great post.
Joby

Post a Comment

Related Posts Plugin for WordPress, Blogger...

About the Author

Dattatrey Sindol is a BI Tech Lead & a passionate SQL Server Developer in a leading IT company.  read more »
Connect with Datta:

Thank You Visitors!

Hi There, Thanks for Visiting my Blog. Please feel free to leave your Comments/Suggestions about any of my Articles/My Blog.

Do Not Copy this Blog's Content !

Protected by Copyscape Online Copyright Checker