home contribute faq download

FunctX XQuery Functions

functx:day-in-year

The day of the year (a number between 1 and 366)

Google
Webxqueryfunctions.com

Description

The functx:day-in-year function returns the day of the year of $date as a number, where 1 is January 1, 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?

XQuery Function Declaration

See XSLT definition.
XQuery Syntax for January 2007 (1.0):
declare namespace functx = "http://www.functx.com"; 
declare function functx:day-in-year 
  ( $date as xs:anyAtomicType? )  as xs:integer? {
       
  days-from-duration(
      xs:date($date) - functx:first-day-of-year($date)) + 1
 } ;
XQuery Syntax for July 2004 - November 2005 (CR):
declare namespace functx = "http://www.functx.com"; 
declare function functx:day-in-year 
  ( $date as xdt:anyAtomicType? )  as xs:integer? {
       
  days-from-duration(
      xs:date($date) - functx:first-day-of-year($date)) + 1
 } ;
XQuery Syntax for May 2003:
declare namespace functx = "http://www.functx.com" 
define function day-in-year 
  ( $date as xdt:anyAtomicType? )  as xs:integer? {
       
  fn:get-days-from-dayTimeDuration(
      xs:date($date) - functx:first-day-of-year($date)) + 1
 }

Examples

XQuery ExampleResults
functx:day-in-year(xs:date('2004-01-01'))
1
functx:day-in-year(
     xs:dateTime('2004-02-01T12:00:13'))
32
functx:day-in-year('2004-02-05')
36

Depends On

functx:first-day-of-yearThe first day of the year of a date

History

Published OnLast UpdatedContributor(s)
2006-06-272007-02-26Priscilla Walmsley, Datypic, pwalmsley@datypic.com, http://www.datypic.com
Need XQuery Help?
D A T Y P I C
Training | Consulting | Development

XQuery by Priscilla WalmsleyGet the book!
XQuery by Priscilla Walmsley