home contribute faq download

FunctX XSLT Functions

functx:day-of-week

The day of the week, from a date

Google
Webxsltfunctions.com

Description

The functx:day-of-week function returns the day of the week of $date as a number, where 0 is Sunday, 1 is Monday, etc.

The $date argument must be castable to xs:date, meaning that it must have the type xs:date or xs:dateTime, or be an xs:string or untyped value of the form YYYY-MM-DD.

Arguments and Return Type

NameTypeDescription
$date xs:anyAtomicType? the date
return value xs:integer?

XSLT Function Declaration

See XQuery definition.
<xsl:function name="functx:day-of-week" as="xs:integer?"
              xmlns:functx="http://www.functx.com">
  <xsl:param name="date" as="xs:anyAtomicType?"/>

  <xsl:sequence select="
  if (empty($date))
  then ()
  else xs:integer((xs:date($date) - xs:date('1901-01-06'))
          div xs:dayTimeDuration('P1D')) mod 7
 "/>

</xsl:function>

Examples

XPath ExampleResultsExplanation
functx:day-of-week(
   xs:date('2004-11-04'))
4
Thursday
functx:day-of-week(
     xs:dateTime('2004-11-04T12:00:13'))
4
Thursday
functx:day-of-week('2004-11-04')
4
Thursday

See Also

functx:day-of-week-name-enThe name of the day of the week, from a date, in English
functx:day-of-week-abbrev-enThe abbreviated day of the week, from a date, in English

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Datypic XSLT Services

Recommended Reading:

XQuery