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| Name | Type | Description |
$date |
xs:anyAtomicType? |
the date |
| return value |
xs:integer? |
XQuery Function Declaration| See XSLT definition. | | XQuery Syntax for January 2007 (1.0): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:day-of-week
( $date as xs:anyAtomicType? ) as xs:integer? {
if (empty($date))
then ()
else xs:integer((xs:date($date) - xs:date('1901-01-06'))
div xs:dayTimeDuration('P1D')) mod 7
} ; | | XQuery Syntax for July 2004 - November 2005 (CR): |
|---|
declare namespace functx = "http://www.functx.com";
declare function functx:day-of-week
( $date as xdt:anyAtomicType? ) as xs:integer? {
if (empty($date))
then ()
else xs:integer((xs:date($date) - xs:date('1901-01-06'))
div xdt:dayTimeDuration('P1D')) mod 7
} ; | | XQuery Syntax for May 2003: |
|---|
declare namespace functx = "http://www.functx.com"
define function day-of-week
( $date as xdt:anyAtomicType? ) as xs:integer? {
if (fn:empty($date))
then ()
else xs:integer((xs:date($date) - xs:date('1901-01-06'))
div xdt:dayTimeDuration('P1D')) mod 7
} |
Examples| XQuery Example | Results | Explanation |
|---|
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 AlsoHistory |
|