days-from-date()

number days-from-date(string)

This function returns a whole number of days, according to the following rules:

  1. If the string parameter represents a legal lexical xsd:date or xsd:dateTime, the return value is equal to the number of days difference between the specified date or dateTime (normalized to UTC) and 1970-01-01.
  2. Hour, minute, and second components are ignored after normalisation.
  3. Any other input parameter causes a return value of NaN.

Examples:

days-from-date("2002-01-01")

returns 11688

days-from-date("1969-12-31")

returns -1

More examples