Microsoft XML SDK 2.6 - XML Reference

formatDate Method

Formats the supplied date using the specified formatting options.

formatDate(varDate, bstrFormat, varDestLocale)

Parameters

varDate
Variant. Date that is to be formatted.
bstrFormat
String. Specified formatting. The following codes are supported:
M Months as 1–12
MM Months as 01–12
MMM Months as Jan–Dec
MMMM Months as January–December
MMMMM Months as the first letter of the month
d Days as 1–31
dd Days as 01–31
ddd Days as Sun–Sat
dddd Days as Sunday–Saturday
yy Years as 00–99
yyyy Years as 1900–9999
varDestLocale [optional]
Variant. Locale to use in determining the correct sequence to be employed in the date. If not supplied, the month-day-year sequence is used.

Note   This parameter is not yet implemented.

Return Value

String. Returns the string containing the date in the requested format.

The formatDate method is derived from the Win32 API call, GetDateFormat. Information on this API can be found at http://msdn.microsoft.com/library/books/devintl/S24B4_a.HTM.

Example

<?xml version='1.0'?>
<?xml-stylesheet type="text/xsl" href="Sample.xsl"?>
<XMLSamples xml:space="preserve"
         xmlns:dt="urn:schemas-microsoft-com:datatypes">
  <FileDetails>
   <Author>Amit S. Kripalani</Author>
   <Date dt:dt="datetime">2000-02-16T15:56:00</Date>
  </FileDetails>
</XMLSamples>

Sample.xsl

<?xml version='1.0'?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/TR/WD-xsl"
      xmlns:dt="urn:schemas-microsoft-com:datatypes">
  <xsl:template match="/">
  <HTML>
  <HEAD>
  </HEAD>
  <BODY> 
   <xsl:for-each select="XMLSamples/FileDetails/Date">
   Date Edited : 
<xsl:eval>
formatDate(this.nodeTypedValue, "MMM dd, yyyy");
</xsl:eval>
   </xsl:for-each>
  </BODY> 
  </HTML>
</xsl:template>
</xsl:stylesheet>

Output

Date Edited : Feb 16, 2000

See Also

Applies To: XTLRuntime Object