Home > Reporting Services > Date Formatting in Reporting Services – list of format codes

Date Formatting in Reporting Services – list of format codes


The Date Formatting article that I wrote earlier seems to be quite popular. As a follow up to that , I stumbled accross the full list of date formatting patterns on MSDN. I haven’t had a chance to try out them all , but here it is :

Format Pattern

Description

d

The day of the month. Single-digit days will not have a leading zero.

dd

The day of the month. Single-digit days will have a leading zero.

ddd

The abbreviated name of the day of the week, as defined in AbbreviatedDayNames

dddd

The full name of the day of the week, as defined in DayNamesTD>

M

The numeric month. Single-digit months will not have a leading zero.

MM

The numeric month. Single-digit months will have a leading zero.

MMM

The abbreviated name of the month, as defined in AbbreviatedMonthNames.

MMMM

The full name of the month, as defined in MonthNames.

y

The year without the century. If the year without the century is less than 10, the year is displayed with no leading zero.

yy

The year without the century. If the year without the century is less than 10, the year is displayed with a leading zero.

yyyy

The year in four digits, including the century.

gg

The period or era. This pattern is ignored if the date to be formatted does not have an associated period or era string.

h

The hour in a 12-hour clock. Single-digit hours will not have a leading zero.

hh

The hour in a 12-hour clock. Single-digit hours will have a leading zero.

H

The hour in a 24-hour clock. Single-digit hours will not have a leading zero.

HH

The hour in a 24-hour clock. Single-digit hours will have a leading zero.

m

The minute. Single-digit minutes will not have a leading zero.

mm

The minute. Single-digit minutes will have a leading zero.

s

The second. Single-digit seconds will not have a leading zero.

ss

The second. Single-digit seconds will have a leading zero.

f

The fraction of a second in single-digit precision. The remaining digits are truncated.

ff

The fraction of a second in double-digit precision. The remaining digits are truncated.

fff

The fraction of a second in three-digit precision. The remaining digits are truncated.

ffff

The fraction of a second in four-digit precision. The remaining digits are truncated.

fffff

The fraction of a second in five-digit precision. The remaining digits are truncated.

ffffff

The fraction of a second in six-digit precision. The remaining digits are truncated.

fffffff

The fraction of a second in seven-digit precision. The remaining digits are truncated.

t

The first character in the AM/PM designator defined in AMDesignator or PMDesignator, if any.

tt

The AM/PM designator defined in AMDesignator or PMDesignator, if any.

z

The time zone offset ("+" or "-" followed by the hour only). Single-digit hours will not have a leading zero. For example, Pacific Standard Time is "-8".

zz

The time zone offset ("+" or "-" followed by the hour only). Single-digit hours will have a leading zero. For example, Pacific Standard Time is "-08".

zzz

The full time zone offset ("+" or "-" followed by the hour and minutes). Single-digit hours and minutes will have leading zeros. For example, Pacific Standard Time is "-08:00".

:

The default time separator defined in TimeSeparator.

/

The default date separator defined in DateSeparator.

% c

Where c is a format pattern if used alone. The "%" character can be omitted if the format pattern is combined with literal characters or other format patterns.

\ c

Where c is any character. Displays the character literally. To display the backslash character, use "\\".
About these ads
Categories: Reporting Services
  1. Ryan
    September 25, 2009 at 5:01 am

    this is so handy! thanks for the post.

  2. Unknown
    April 5, 2010 at 12:11 pm

    How do we set the above date time formats on the report server? Currently we have a String report parameter which accepts date time values. If the values are passed in m/d/yyyy hh:mm:ss AM/PM then only they are accepted otherwise ReportParameterValueNotSetException is thrown with the following message : This report requires a default or user-defined value for the report parameter \’param1\’. To run or subscribe to this report, you must provide a parameter value.I am using SQL Server SP3 (9.0.4035)

  3. Unknown
    April 6, 2010 at 7:20 am

    The link which you shared is about changing the display of the date time fields. The problem solution I am looking for is about passing parameter values to a string queried report parameter accepting date time values. I guess there should be a configuration setting on the report server which specifies the date time format in which the report parameter values are accepted which currently is set to "m/d/yyyy hh:mm:ss AM/PM".

  4. Thavash
    April 7, 2010 at 6:53 pm

    Re: No Name – that is strange , what is the type of the parameter ? If it is a string I don\’t think that that will generate the error you are seeing

  5. Phil
    October 21, 2011 at 4:28 pm

    Big help – Thanks.

  6. Tom
    January 23, 2012 at 4:51 pm

    Brilliant article. I didn’t know it was as simple as this or that you could combine the letters to get the results you want! Thanks.

  7. Derrick
    December 11, 2012 at 7:48 am

    This is fantastic! I have been looking for something like this for years. I will definitely be saving this post.

  8. Linda
    January 23, 2013 at 5:27 pm

    Where is your previous article please?

  9. May 10, 2013 at 7:58 pm

    Hi there! I could have sworn I’ve been to this site before but after browsing through a few of the articles I realized it’s new to
    me. Anyhow, I’m definitely delighted I found it and I’ll
    be bookmarking it and checking back regularly!

  10. Ian
    July 28, 2013 at 2:02 am

    Hi there! This is my first visit to your blog!
    We are a team of volunteers and starting
    a new initiative in a community in the same niche.
    Your blog provided us useful information to work on.
    You have done a marvellous job!

  1. August 24, 2012 at 6:57 am

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

Follow

Get every new post delivered to your Inbox.

Join 57 other followers

%d bloggers like this: