ddwrt FormatDate and FormatDateTime

As evidenced in the latest blogs, I’ve been spending a lot of time aggregating my content types into customized Content Query Web Parts (CWQP).  Soon, I’m going to need to branch out to other web parts.

Something I needed to research today which took longer than it should have:  how do you format the datetime elements when you use the ddwrt namespace?

Here’s a resource for customizing the CQWP: http://www.microsoft.com/belux/msdn/nl/community/columns/stevenvandecraen/contentquerywebpart.mspx
This page helped: http://msdn.microsoft.com/en-us/library/aa505323.aspx#officesharepointddwrt_formatdate
This provided more examples of the FormatDateTime formatting codes (like YYYYMMDDThh:mm): http://msdn.microsoft.com/en-us/library/8kb3ddd4.aspx
Here’s a list of languages with their LCID: http://support.microsoft.com/default.aspx?id=221435
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

I also learned that "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:

<Query>
<Where>
<Gt>
<FieldRef Name="EventDate" />
<Value Type="DateTime">2005-5-27T00:00:00Z</Value>
</Gt>
</Where>
</Query> 

Published in: on May 9, 2008 at 4:22 am  Leave a Comment  

The URI to TrackBack this entry is: http://autosponge.wordpress.com/2008/05/09/ddwrt-formatdate-and-formatdatetime/trackback/

RSS feed for comments on this post.

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 )

Connecting to %s

Follow

Get every new post delivered to your Inbox.