DotNet Development, SharePoint Customizing, Silverlight, MS Infrastructure and other tips and tricks

ddwrt:FormatDate with different FormatFlags

Posted by PANVEGA on December 8, 2008

I needed to use the ddwrt functions in my content query web part. Using the FormatFlags you can easily transform the format you wish.

Add the following namespace attribute to the root xsl:stylesheet element


This provided more examples of the FormatDateTime formatting codes (like YYYYMMDDThh:mm):

Here’s a list of languages with their LCID:

Language packs for Office SharePoint Server 2007 are not bundled into multilingual installation packages. You must install a specific language pack for each language that you want to support. Also, language packs must be installed on each of your front-end Web servers to ensure that each Web server can render content in the specified language.

The following table lists the language packs that are available for Office SharePoint Server 2007.

German Germany 1031
English United States 1033
Japanese Japan 1041

The FormatDate function date formates are expressed with an integer, here are a couple of examples:
ddwrt:FormatDate(string(@EventDate), 1033, 5) => MM/DD/YYYY
ddwrt:FormatDate(string(@EventDate), 1033, 1) => MM/DD/YYYY HH:MM AM/PM


Note that in the FormatDate function I used 2 hard coded values – 3081 which is the LCID for German (so the date will be formatted to Germany date format) and 5 or 1 are the different FormatFlags which specifies the what do I want to display – date, time, date and time ect.

Sharepoint works with dates in the ISO8601 format: yyyy-mm-ddThh:mm:ssZ so when I delve into CAML I can write stuff like this:

<FieldRef Name=”EventDate” />
<Value Type=”DateTime”>2005-5-27T00:00:00Z</Value>

More links:


4 Responses to “ddwrt:FormatDate with different FormatFlags”

  1. […] with Date formats again in SharePoint, and came across a  good tip from Panvega worth a shout – Using ddwrt:FormatDate in the CQWP. I needed to take the Publishing date for a page and reformat it (I don’t need […]

  2. Jordan J said

    Based on the chart your example is incorrect.

    ddwrt:FormatDate(string(@EventDate), 1033, 5) => MM/DD/YYYY
    ddwrt:FormatDate(string(@EventDate), 1033, 1) => MM/DD/YYYY HH:MM AM/PM

    Change it to

    ddwrt:FormatDate(string(@EventDate), 1033, 1) => MM/DD/YYYY
    ddwrt:FormatDate(string(@EventDate), 1033, 5) => MM/DD/YYYY HH:MM AM/PM

    Thanks for posting this chart.

  3. PANVEGA said

    Thanks for that. All possible formats you are going to find in the LCID List above.

  4. Thank you! I am still learning working with Sharepoint.

Leave a Reply

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

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

Google+ photo

You are commenting using your Google+ 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 )


Connecting to %s

%d bloggers like this: