ddwrt:FormatDate with different FormatFlags

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

xmlns:ddwrt="http://schemas.microsoft.com/WebParts/v2/DataView/runtime"

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

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

dateflags

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:

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

More links:

http://msdn.microsoft.com/en-us/library/aa505323.aspx#officesharepointddwrt_formatdate

原文地址:https://www.cnblogs.com/frankzye/p/1833624.html