XPath/XQuery Functions: Date and Time

www.altova.com Expand/Collapse All Print this Topic Previous Page Up One Level Next page

Home >  Appendices > XSLT and XPath/XQuery Functions > Altova Extension Functions >

XPath/XQuery Functions: Date and Time

Altova's date/time extension functions can be used in XPath and XQuery expressions and provide additional functionality for the processing of data held as XML Schema's various date and time datatypes. The functions in this section can be used with Altova's XPath 3.0 and XQuery 3.0 engines. They are available in XPath/XQuery contexts.

 

Note about naming of functions and language applicability

Altova extension functions can be used in XPath/XQuery expressions. They provide additional functionality to the functionality that is available in the standard library of XPath, XQuery, and XSLT functions. Altova extension functions are in the Altova extension functions namespace, http://www.altova.com/xslt-extensions, and are indicated in this section with the prefix altova:, which is assumed to be bound to this namespace. Note that, in future versions of your product, support for a function might be discontinued or the behavior of individual functions might change. Consult the documentation of future releases for information about support for Altova extension functions in that release.

 

XPath functions (used in XPath expressions in XSLT):

XP1 XP2 XP3.1

XSLT functions (used in XPath expressions in XSLT):

Xslt1 XSLT2 XSLT3

XQuery functions (used in XQuery expressions in XQuery):

XQ1 XQ3.1

 

Click to expand/collapseGrouped by functionality
Click to expand/collapseGrouped alphabetically

 

[ Top ]

 

 

Add a duration to xs:dateTime     XP3.1 XQ3.1

These functions add a duration to xs:dateTime and return xs:dateTime. The xs:dateTime type has a format of CCYY-MM-DDThh:mm:ss.sss. This is a concatenation of the xs:date and xs:time formats separated by the letter T. A timezone suffix +01:00 (for example) is optional.

 

Click to expand/collapseadd-years-to-dateTime [altova:]

altova:add-years-to-dateTime(DateTime as xs:dateTime, Years as xs:integer) as xs:dateTime     XP3.1 XQ3.1

Adds a duration in years to an xs:dateTime (see examples below). The second argument is the number of years to be added to the xs:dateTime supplied as the first argument. The result is of type xs:dateTime.

altova:add-years-to-dateTime(xs:dateTime("2014-01-15T14:00:00"), 10) returns 2024-01-15T14:00:00
altova:add-years-to-dateTime(xs:dateTime("2014-01-15T14:00:00"), -4) returns 2010-01-15T14:00:00

 

 

Click to expand/collapseadd-months-to-dateTime [altova:]

altova:add-months-to-dateTime(DateTime as xs:dateTime, Months as xs:integer) as xs:dateTime     XP3.1 XQ3.1

Adds a duration in months to an xs:dateTime (see examples below). The second argument is the number of months to be added to the xs:dateTime supplied as the first argument. The result is of type xs:dateTime.

altova:add-months-to-dateTime(xs:dateTime("2014-01-15T14:00:00"), 10) returns 2014-11-15T14:00:00
altova:add-months-to-dateTime(xs:dateTime("2014-01-15T14:00:00"), -2) returns 2013-11-15T14:00:00

 

 

Click to expand/collapseadd-days-to-dateTime [altova:]

altova:add-days-to-dateTime(DateTime as xs:dateTime, Days as xs:integer) as xs:dateTime     XP3.1 XQ3.1

Adds a duration in days to an xs:dateTime (see examples below). The second argument is the number of days to be added to the xs:dateTime supplied as the first argument. The result is of type xs:dateTime.

altova:add-days-to-dateTime(xs:dateTime("2014-01-15T14:00:00"), 10) returns 2014-01-25T14:00:00
altova:add-days-to-dateTime(xs:dateTime("2014-01-15T14:00:00"), -8) returns 2014-01-07T14:00:00

 

 

Click to expand/collapseadd-hours-to-dateTime [altova:]

altova:add-hours-to-dateTime(DateTime as xs:dateTime, Hours as xs:integer) as xs:dateTime     XP3.1 XQ3.1

Adds a duration in hours to an xs:dateTime (see examples below). The second argument is the number of hours to be added to the xs:dateTime supplied as the first argument. The result is of type xs:dateTime.

altova:add-hours-to-dateTime(xs:dateTime("2014-01-15T13:00:00"), 10) returns 2014-01-15T23:00:00
altova:add-hours-to-dateTime(xs:dateTime("2014-01-15T13:00:00"), -8) returns 2014-01-15T05:00:00

 

 

Click to expand/collapseadd-minutes-to-dateTime [altova:]

altova:add-minutes-to-dateTime(DateTime as xs:dateTime, Minutes as xs:integer) as xs:dateTime     XP3.1 XQ3.1

Adds a duration in minutes to an xs:dateTime (see examples below). The second argument is the number of minutes to be added to the xs:dateTime supplied as the first argument. The result is of type xs:dateTime.

altova:add-minutes-to-dateTime(xs:dateTime("2014-01-15T14:10:00"), 45) returns 2014-01-15T14:55:00
altova:add-minutes-to-dateTime(xs:dateTime("2014-01-15T14:10:00"), -5) returns 2014-01-15T14:05:00

 

 

Click to expand/collapseadd-seconds-to-dateTime [altova:]

altova:add-seconds-to-dateTime(DateTime as xs:dateTime, Seconds as xs:integer) as xs:dateTime     XP3.1 XQ3.1

Adds a duration in seconds to an xs:dateTime (see examples below). The second argument is the number of seconds to be added to the xs:dateTime supplied as the first argument. The result is of type xs:dateTime.

altova:add-seconds-to-dateTime(xs:dateTime("2014-01-15T14:00:10"), 20) returns 2014-01-15T14:00:30
altova:add-seconds-to-dateTime(xs:dateTime("2014-01-15T14:00:10"), -5) returns 2014-01-15T14:00:05

 

 

[ Top ]

 

 

Add a duration to xs:date     XP3.1 XQ3.1

These functions add a duration to xs:date and return xs:date. The xs:date type has a format of CCYY-MM-DD.

 

Click to expand/collapseadd-years-to-date [altova:]

altova:add-years-to-date(Date as xs:date, Years as xs:integer) as xs:date     XP3.1 XQ3.1

Adds a duration in years to a date. The second argument is the number of years to be added to the xs:date supplied as the first argument. The result is of type xs:date.

altova:add-years-to-date(xs:date("2014-01-15"), 10) returns 2024-01-15
altova:add-years-to-date(xs:date("2014-01-15"), -4) returns 2010-01-15

 

 

Click to expand/collapseadd-months-to-date [altova:]

altova:add-months-to-date(Date as xs:date, Months as xs:integer) as xs:date     XP3.1 XQ3.1

Adds a duration in months to a date. The second argument is the number of months to be added to the xs:date supplied as the first argument. The result is of type xs:date.

altova:add-months-to-date(xs:date("2014-01-15"), 10) returns 2014-11-15
altova:add-months-to-date(xs:date("2014-01-15"), -2) returns 2013-11-15

 

 

Click to expand/collapseadd-days-to-date [altova:]

altova:add-days-to-date(Date as xs:date, Days as xs:integer) as xs:date     XP3.1 XQ3.1

Adds a duration in days to a date. The second argument is the number of days to be added to the xs:date supplied as the first argument. The result is of type xs:date.

altova:add-days-to-date(xs:date("2014-01-15"), 10) returns 2014-01-25
altova:add-days-to-date(xs:date("2014-01-15"), -8) returns 2014-01-07

 

 

[ Top ]

 

 

Format and retrieve durations     XP3.1 XQ3.1

These functions add a duration to xs:date and return xs:date. The xs:date type has a format of CCYY-MM-DD.

 

Click to expand/collapseformat-duration [altova:]

altova:format-duration(Duration as xs:duration, Picture as xs:string) as xs:string     XP3.1 XQ3.1

Formats a duration, which is submitted as the first argument, according to a picture string submitted as the second argument. The output is a text string formatted according to the picture string.

altova:format-duration(xs:duration("P2DT2H53M11.7S"), "Days:[D01] Hours:[H01] Minutes:[m01] Seconds:[s01] Fractions:[f0]") returns "Days:02 Hours:02 Minutes:53 Seconds:11 Fractions:7"
altova:format-duration(xs:duration("P3M2DT2H53M11.7S"), "Months:[M01] Days:[D01] Hours:[H01] Minutes:[m01]") returns "Months:03 Days:02 Hours:02 Minutes:53"

 

 

Click to expand/collapseparse-duration [altova:]

altova:parse-duration(InputString as xs:string, Picture as xs:string) as xs:duration     XP3.1 XQ3.1

Takes a patterned string as the first argument, and a picture string as the second argument. The input string is parsed on the basis of the picture string, and an xs:duration is returned.

altova:parse-duration("Days:02 Hours:02 Minutes:53 Seconds:11 Fractions:7"), "Days:[D01] Hours:[H01] Minutes:[m01] Seconds:[s01] Fractions:[f0]") returns "P2DT2H53M11.7S"
altova:parse-duration("Months:03 Days:02 Hours:02 Minutes:53 Seconds:11 Fractions:7", "Months:[M01] Days:[D01] Hours:[H01] Minutes:[m01]") returns "P3M2DT2H53M"

 

 

[ Top ]

 

Add a duration to xs:time     XP3.1 XQ3.1

These functions add a duration to xs:time and return xs:time. The xs:time type has a lexical form of hh:mm:ss.sss. An optional time zone may be suffixed. The letter Z indicates Coordinated Universal Time (UTC). All other time zones are represented by their difference from UTC in the format +hh:mm, or -hh:mm. If no time zone value is present, it is considered unknown; it is not assumed to be UTC.

 

Click to expand/collapseadd-hours-to-time [altova:]

altova:add-hours-to-time(Time as xs:time, Hours as xs:integer) as xs:time     XP3.1 XQ3.1

Adds a duration in hours to a time. The second argument is the number of hours to be added to the xs:time supplied as the first argument. The result is of type xs:time.

altova:add-hours-to-time(xs:time("11:00:00"), 10) returns 21:00:00
altova:add-hours-to-time(xs:time("11:00:00"), -7) returns 04:00:00

 

 

Click to expand/collapseadd-minutes-to-time [altova:]

altova:add-minutes-to-time(Time as xs:time, Minutes as xs:integer) as xs:time     XP3.1 XQ3.1

Adds a duration in minutes to a time. The second argument is the number of minutes to be added to the xs:time supplied as the first argument. The result is of type xs:time.

altova:add-minutes-to-time(xs:time("14:10:00"), 45) returns 14:55:00
altova:add-minutes-to-time(xs:time("14:10:00"), -5) returns 14:05:00

 

 

Click to expand/collapseadd-seconds-to-time [altova:]

altova:add-seconds-to-time(Time as xs:time, Minutes as xs:integer) as xs:time     XP3.1 XQ3.1

Adds a duration in seconds to a time. The second argument is the number of seconds to be added to the xs:time supplied as the first argument. The result is of type xs:time. The Seconds component can be in the range of 0 to 59.999.

altova:add-seconds-to-time(xs:time("14:00:00"), 20) returns 14:00:20
altova:add-seconds-to-time(xs:time("14:00:00"), 20.895) returns 14:00:20.895

 

 

[ Top ]

 

 

Remove the timezone part from date/time datatypes     XP3.1 XQ3.1

These functions remove the timezone from the current xs:dateTime, xs:date, or xs:time values, respectively. Note that the difference between xs:dateTime and xs:dateTimeStamp is that in the case of the latter the timezone part is required (while it is optional in the case of the former). So the format of an xs:dateTimeStamp value is: CCYY-MM-DDThh:mm:ss.sss±hh:mm. or CCYY-MM-DDThh:mm:ss.sssZ. If the date and time is read from the system clock as xs:dateTimeStamp, the current-dateTime-no-TZ() function can be used to remove the timezone if so required.

 

Click to expand/collapsecurrent-date-no-TZ [altova:]

altova:current-date-no-TZ() as xs:date     XP3.1 XQ3.1

This function takes no argument. It removes the timezone part of current-date() (which is the current date according to the system clock) and returns an xs:date value.

If the current date is 2014-01-15+01:00:

 

altova:current-date-no-TZ() returns 2014-01-15

 

 

Click to expand/collapsecurrent-dateTime-no-TZ [altova:]

altova:current-dateTime-no-TZ() as xs:dateTime     XP3.1 XQ3.1

This function takes no argument. It removes the timezone part of current-dateTime() (which is the current date-and-time according to the system clock) and returns an xs:dateTime value.

If the current dateTime is 2014-01-15T14:00:00+01:00:

 

altova:current-dateTime-no-TZ() returns 2014-01-15T14:00:00

 

 

Click to expand/collapsecurrent-time-no-TZ [altova:]

altova:current-time-no-TZ() as xs:time     XP3.1 XQ3.1

This function takes no argument. It removes the timezone part of current-time() (which is the current time according to the system clock) and returns an xs:time value.

If the current time is 14:00:00+01:00:

 

altova:current-time-no-TZ() returns 14:00:00

 

 

Click to expand/collapsedate-no-TZ [altova:]

altova:date-no-TZ(InputDate as xs:date) as xs:date     XP3.1 XQ3.1

This function takes an xs:date argument, removes the timezone part from it, and returns an xs:date value. Note that the date is not modified.

altova:date-no-TZ(xs:date("2014-01-15+01:00")) returns 2014-01-15

 

 

Click to expand/collapsedateTime-no-TZ [altova:]

altova:dateTime-no-TZ(InputDateTime as xs:dateTime) as xs:dateTime     XP3.1 XQ3.1

This function takes an xs:dateTime argument, removes the timezone part from it, and returns an xs:dateTime value. Note that neither the date nor the time is modified.

altova:dateTime-no-TZ(xs:date("2014-01-15T14:00:00+01:00")) returns 2014-01-15T14:00:00

 

 

Click to expand/collapsetime-no-TZ [altova:]

altova:time-no-TZ(InputTime as xs:time) as xs:time     XP3.1 XQ3.1

This function takes an xs:time argument, removes the timezone part from it, and returns an xs:time value. Note that the time is not modified.

altova:time-no-TZ(xs:time("14:00:00+01:00")) returns 14:00:00

 

 

[ Top ]

 

Return the number of days, hours, minutes, seconds from durations     XP3.1 XQ3.1

These functions return the number of days in a month, and the number of hours, minutes, and seconds, respectively, from durations.

 

Click to expand/collapsedays-in-month [altova:]

altova:days-in-month(Year as xs:integer, Month as xs:integer) as xs:integer     XP3.1 XQ3.1

Returns the number of days in the specified month. The month is specified by means of the Year and Month arguments.

altova:days-in-month(2018, 10) returns 31
altova:days-in-month(2018,  2) returns 28
altova:days-in-month(2020,  2) returns 29

 

 

Click to expand/collapsehours-from-dayTimeDuration-accumulated

altova:hours-from-dayTimeDuration-accumulated(DayAndTime as xs:duration) as xs:integer     XP3.1 XQ3.1

Returns the total number of hours in the duration submitted by the DayAndTime argument (which is of type xs:duration). The hours in the Day and Time components are added together to give a result that is an integer. A new hour is counted for a full 60 minutes. Negative durations result in a negative hour value.

altova:hours-from-dayTimeDuration-accumulated(xs:duration("P5D") returns 120, which is the total number of hours in 5 days.
altova:hours-from-dayTimeDuration-accumulated(xs:duration("P5DT2H") returns 122, which is the total number of hours in 5 days plus 2 hours.
altova:hours-from-dayTimeDuration-accumulated(xs:duration("P5DT2H60M") returns 123, which is the total number of hours in 5 days plus 2 hours and 60 mins.
altova:hours-from-dayTimeDuration-accumulated(xs:duration("P5DT2H119M") returns 123, which is the total number of hours in 5 days plus 2 hours and 119 mins.
altova:hours-from-dayTimeDuration-accumulated(xs:duration("P5DT2H120M") returns 124, which is the total number of hours in 5 days plus 2 hours and 120 mins.
altova:hours-from-dayTimeDuration-accumulated(xs:duration("-P5DT2H") returns -122

 

 

Click to expand/collapseminutes-from-dayTimeDuration-accumulated

altova:minutes-from-dayTimeDuration-accumulated(DayAndTime as xs:duration) as xs:integer     XP3.1 XQ3.1

Returns the total number of minutes in the duration submitted by the DayAndTime argument (which is of type xs:duration). The minutes in the Day and Time components are added together to give a result that is an integer. Negative durations result in a negative minute value.

altova:minutes-from-dayTimeDuration-accumulated(xs:duration("PT60M") returns 60
altova:minutes-from-dayTimeDuration-accumulated(xs:duration("PT1H") returns 60, which is the total number of minutes in 1 hour.
altova:minutes-from-dayTimeDuration-accumulated(xs:duration("PT1H40M") returns 100
altova:minutes-from-dayTimeDuration-accumulated(xs:duration("P1D") returns 1440, which is the total number of minutes in 1 day.
altova:minutes-from-dayTimeDuration-accumulated(xs:duration("-P1DT60M") returns -1500

 

 

Click to expand/collapseseconds-from-dayTimeDuration-accumulated

altova:seconds-from-dayTimeDuration-accumulated(DayAndTime as xs:duration) as xs:integer     XP3.1 XQ3.1

Returns the total number of seconds in the duration submitted by the DayAndTime argument (which is of type xs:duration). The seconds in the Day and Time components are added together to give a result that is an integer. Negative durations result in a negative seconds value.

altova:seconds-from-dayTimeDuration-accumulated(xs:duration("PT1M") returns 60, which is the total number of seconds in 1 minute.
altova:seconds-from-dayTimeDuration-accumulated(xs:duration("PT1H") returns 3600, which is the total number of seconds in 1 hour.
altova:seconds-from-dayTimeDuration-accumulated(xs:duration("PT1H2M") returns 3720
altova:seconds-from-dayTimeDuration-accumulated(xs:duration("P1D") returns 86400, which is the total number of seconds in 1 day.
altova:seconds-from-dayTimeDuration-accumulated(xs:duration("-P1DT1M") returns -86460

 

 

 

Return the weekday from xs:dateTime or xs:date     XP3.1 XQ3.1

These functions return the weekday (as an integer) from xs:dateTime or xs:date. The days of the week are numbered (using the American format) from 1 to 7, with Sunday=1. In the European format, the week starts with Monday (=1). The American format, where Sunday=1, can be set by using the integer 0 where an integer is accepted to indicate the format.

 

Click to expand/collapseweekday-from-dateTime [altova:]

altova:weekday-from-dateTime(DateTime as xs:dateTime) as xs:integer     XP3.1 XQ3.1

Takes a date-with-time as its single argument and returns the day of the week of this date as an integer. The weekdays are numbered starting with Sunday=1. If the European format is required (where Monday=1), use the other signature of this function (see next signature below).

altova:weekday-from-dateTime(xs:dateTime("2014-02-03T09:00:00")) returns 2, which would indicate a Monday.

 

altova:weekday-from-dateTime(DateTime as xs:dateTime, Format as xs:integer) as xs:integer     XP3.1 XQ3.1

Takes a date-with-time as its first argument and returns the day of the week of this date as an integer. The weekdays are numbered starting with Monday=1. If the second (integer) argument is 0, then the weekdays are numbered 1 to 7 starting with Sunday=1. If the second argument is an integer other than 0, then Monday=1. If there is no second argument, the function is read as having the other signature of this function (see previous signature).

altova:weekday-from-dateTime(xs:dateTime("2014-02-03T09:00:00"), 1) returns 1, which would indicate a Monday
altova:weekday-from-dateTime(xs:dateTime("2014-02-03T09:00:00"), 4) returns 1, which would indicate a Monday
altova:weekday-from-dateTime(xs:dateTime("2014-02-03T09:00:00"), 0) returns 2, which would indicate a Monday.

 

 

Click to expand/collapseweekday-from-date [altova:]

altova:weekday-from-date(Date as xs:date) as xs:integer     XP3.1 XQ3.1

Takes a date as its single argument and returns the day of the week of this date as an integer. The weekdays are numbered starting with Sunday=1. If the European format is required (where Monday=1), use the other signature of this function (see next signature below).

altova:weekday-from-date(xs:date("2014-02-03+01:00")) returns 2, which would indicate a Monday.

 

altova:weekday-from-date(Date as xs:date, Format as xs:integer) as xs:integer     XP3.1 XQ3.1

Takes a date as its first argument and returns the day of the week of this date as an integer. The weekdays are numbered starting with Monday=1. If the second (Format) argument is 0, then the weekdays are numbered 1 to 7 starting with Sunday=1. If the second argument is an integer other than 0, then Monday=1. If there is no second argument, the function is read as having the other signature of this function (see previous signature).

altova:weekday-from-date(xs:date("2014-02-03"), 1) returns 1, which would indicate a Monday
altova:weekday-from-date(xs:date("2014-02-03"), 4) returns 1, which would indicate a Monday
altova:weekday-from-date(xs:date("2014-02-03"), 0) returns 2, which would indicate a Monday.

 

 

[ Top ]

 

 

Return the week number from xs:dateTime or xs:date     XP2 XQ1 XP3.1 XQ3.1

These functions return the week number (as an integer) from xs:dateTime or xs:date. Week-numbering is available in the US, ISO/European, and Islamic calendar formats. Week-numbering is different in these calendar formats because the week is considered to start on different days (on Sunday in the US format, Monday in the ISO/European format, and Saturday in the Islamic format).

 

Click to expand/collapseweeknumber-from-date [altova:]

altova:weeknumber-from-date(Date as xs:date, Calendar as xs:integer) as xs:integer     XP2 XQ1 XP3.1 XQ3.1

Returns the week number of the submitted Date argument as an integer. The second argument (Calendar) specifies the calendar system to follow.

Supported Calendar values are:

 

0 = US calendar (week starts Sunday)
1 = ISO standard, European calendar (week starts Monday)
2 = Islamic calendar (week starts Saturday)

 

Default is 0.

 

altova:weeknumber-from-date(xs:date("2014-03-23"), 0) returns 13
altova:weeknumber-from-date(xs:date("2014-03-23"), 1) returns 12
altova:weeknumber-from-date(xs:date("2014-03-23"), 2) returns 13
altova:weeknumber-from-date(xs:date("2014-03-23")   ) returns 13

 

The day of the date in the examples above (2014-03-23) is Sunday. So the US and Islamic calendars are one week ahead of the European calendar on this day.

 

 

Click to expand/collapseweeknumber-from-dateTime [altova:]

altova:weeknumber-from-dateTime(DateTime as xs:dateTime, Calendar as xs:integer) as xs:integer     XP2 XQ1 XP3.1 XQ3.1

Returns the week number of the submitted DateTime argument as an integer. The second argument (Calendar) specifies the calendar system to follow.

Supported Calendar values are:

 

0 = US calendar (week starts Sunday)
1 = ISO standard, European calendar (week starts Monday)
2 = Islamic calendar (week starts Saturday)

 

Default is 0.

 

altova:weeknumber-from-dateTime(xs:dateTime("2014-03-23T00:00:00"), 0) returns 13
altova:weeknumber-from-dateTime(xs:dateTime("2014-03-23T00:00:00"), 1) returns 12
altova:weeknumber-from-dateTime(xs:dateTime("2014-03-23T00:00:00"), 2) returns 13
altova:weeknumber-from-dateTime(xs:dateTime("2014-03-23T00:00:00")   ) returns 13

 

The day of the dateTime in the examples above (2014-03-23T00:00:00) is Sunday. So the US and Islamic calendars are one week ahead of the European calendar on this day.

 

 

[ Top ]

 

Build date, time, and duration datatypes from their lexical components     XP3.1 XQ3.1

The functions take the lexical components of the xs:date, xs:time, or xs:duration datatype as input arguments and combine them to build the respective datatype.

 

Click to expand/collapsebuild-date [altova:]

altova:build-date(Year as xs:integerMonth as xs:integerDate as xs:integer) as xs:date     XP3.1 XQ3.1

The first, second, and third arguments are, respectively, the year, month, and date. They are combined to build a value of xs:date type. The values of the integers must be within the correct range of that particular date part. For example, the second argument (for the month part) should not be greater than 12.

altova:build-date(2014, 2, 03) returns 2014-02-03

 

 

Click to expand/collapsebuild-time [altova:]

altova:build-time(Hours as xs:integerMinutes as xs:integerSeconds as xs:integer) as xs:time     XP3.1 XQ3.1

The first, second, and third arguments are, respectively, the hour (0 to 23), minutes (0 to 59), and seconds (0 to 59) values. They are combined to build a value of xs:time type. The values of the integers must be within the correct range of that particular time part. For example, the second (Minutes) argument should not be greater than 59. To add a timezone part to the value, use the other signature of this function (see next signature).

altova:build-time(23, 4, 57) returns 23:04:57

 

altova:build-time(Hours as xs:integerMinutes as xs:integerSeconds as xs:integerTimeZone as xs:string) as xs:time     XP3.1 XQ3.1

The first, second, and third arguments are, respectively, the hour (0 to 23), minutes (0 to 59), and seconds (0 to 59) values. The fourth argument is a string that provides the timezone part of the value. The four arguments are combined to build a value of xs:time type. The values of the integers must be within the correct range of that particular time part. For example, the second (Minutes) argument should not be greater than 59.

altova:build-time(23, 4, 57, '+1') returns 23:04:57+01:00

 

 

Click to expand/collapsebuild-duration [altova:]

altova:build-duration(Years as xs:integerMonths as xs:integer) as xs:yearMonthDuration     XP3.1 XQ3.1

Takes two arguments to build a value of type xs:yearMonthDuration. The first arguments provides the Years part of the duration value, while the second argument provides the Months part. If the second (Months) argument is greater than or equal to 12, then the integer is divided by 12; the quotient is added to the first argument to provide the Years part of the duration value while the remainder (of the division) provides the Months part. To build a duration of type xs:dayTimeDuration., see the next signature.

altova:build-duration(2, 10) returns P2Y10M
altova:build-duration(14, 27) returns P16Y3M
altova:build-duration(2, 24) returns P4Y

 

altova:build-duration(Days as xs:integerHours as xs:integerMinutes as xs:integerSeconds as xs:integer) as xs:dayTimeDuration     XP3.1 XQ3.1

Takes four arguments and combines them to build a value of type xs:dayTimeDuration. The first argument provides the Days part of the duration value, the second, third, and fourth arguments provide, respectively, the Hours, Minutes, and Seconds parts of the duration value. Each of the three Time arguments is converted to an equivalent value in terms of the next higher unit and the result is used for calculation of the total duration value. For example, 72 seconds is converted to 1M+12S (1 minute and 12 seconds), and this value is used for calculation of the total duration value. To build a duration of type xs:yearMonthDuration., see the previous signature.

altova:build-duration(2, 10, 3, 56) returns P2DT10H3M56S
altova:build-duration(1, 0, 100, 0) returns P1DT1H40M
altova:build-duration(1, 0, 0, 3600) returns P1DT1H

 

 

[ Top ]

 

Construct date, dateTime, and time datatypes from string input     XP2 XQ1 XP3.1 XQ3.1

These functions take strings as arguments and construct xs:date, xs:dateTime, or xs:time datatypes. The string is analyzed for components of the datatype based on a submitted pattern argument.

 

Click to expand/collapseparse-date [altova:]

altova:parse-date(Date as xs:string, DatePattern as xs:string) as xs:date     XP2 XQ1 XP3.1 XQ3.1

Returns the input string Date as an xs:date value. The second argument DatePattern specifies the pattern (sequence of components) of the input string. DatePattern is described with the component specifiers listed below and with component separators that can be any character. See the examples below.

D

Date

M

Month

Y

Year

 

The pattern in DatePattern must match the pattern in Date. Since the output is of type xs:date, the output will always have the lexical format YYYY-MM-DD.

 

altova:parse-date(xs:string("09-12-2014"), "[D]-[M]-[Y]") returns 2014-12-09
altova:parse-date(xs:string("09-12-2014"), "[M]-[D]-[Y]") returns 2014-09-12
altova:parse-date("06/03/2014", "[M]/[D]/[Y]") returns 2014-06-03
altova:parse-date("06 03 2014", "[M] [D] [Y]") returns 2014-06-03
altova:parse-date("6 3 2014", "[M] [D] [Y]") returns 2014-06-03

 

 

Click to expand/collapseparse-dateTime [altova:]

altova:parse-dateTime(DateTime as xs:string, DateTimePattern as xs:string) as xs:dateTime     XP2 XQ1 XP3.1 XQ3.1

Returns the input string DateTime as an xs:dateTime value.The second argument DateTimePattern specifies the pattern (sequence of components) of the input string. DateTimePattern is described with the component specifiers listed below and with component separators that can be any character. See the examples below.

D

Date

M

Month

Y

Year

H

Hour

m

minutes

s

seconds

 

The pattern in DateTimePattern must match the pattern in DateTime. Since the output is of type xs:dateTime, the output will always have the lexical format YYYY-MM-DDTHH:mm:ss.

 

altova:parse-dateTime(xs:string("09-12-2014 13:56:24"), "[M]-[D]-[Y] [H]:[m]:[s]") returns 2014-09-12T13:56:24
altova:parse-dateTime("time=13:56:24; date=09-12-2014", "time=[H]:[m]:[s]; date=[D]-[M]-[Y]") returns 2014-12-09T13:56:24

 

 

Click to expand/collapseparse-time [altova:]

altova:parse-time(Time as xs:string, TimePattern as xs:string) as xs:time     XP2 XQ1 XP3.1 XQ3.1

Returns the input string Time as an xs:time value.The second argument TimePattern specifies the pattern (sequence of components) of the input string. TimePattern is described with the component specifiers listed below and with component separators that can be any character. See the examples below.

H

Hour

m

minutes

s

seconds

 

The pattern in TimePattern must match the pattern in Time. Since the output is of type xs:time, the output will always have the lexical format HH:mm:ss.

 

altova:parse-time(xs:string("13:56:24"), "[H]:[m]:[s]") returns 13:56:24
altova:parse-time("13-56-24", "[H]-[m]") returns 13:56:00
altova:parse-time("time=13h56m24s", "time=[H]h[m]m[s]s") returns 13:56:24
altova:parse-time("time=24s56m13h", "time=[s]s[m]m[H]h") returns 13:56:24

 

 

[ Top ]

 

Age-related functions     XP3.1 XQ3.1

These functions return the age as calculated (i) between one input argument date and the current date, or (ii) between two input argument dates. The altova:age function returns the age in terms of years, the altova:age-details function returns the age as a sequence of three integers giving the years, months, and days of the age.

 

Click to expand/collapseage [altova:]

altova:age(StartDate as xs:date) as xs:integer     XP3.1 XQ3.1

Returns an integer that is the age in years of some object, counting from a start-date submitted as the argument and ending with the current date (taken from the system clock). If the input argument is a date anything greater than or equal to one year in the future, the return value will be negative.

If the current date is 2014-01-15:

 

altova:age(xs:date("2013-01-15")) returns 1
altova:age(xs:date("2013-01-16")) returns 0
altova:age(xs:date("2015-01-15")) returns -1
altova:age(xs:date("2015-01-14")) returns 0

 

altova:age(StartDate as xs:dateEndDate as xs:date) as xs:integer     XP3.1 XQ3.1

Returns an integer that is the age in years of some object, counting from a start-date that is submitted as the first argument up to an end-date that is the second argument. The return value will be negative if the first argument is one year or more later than the second argument.

If the current date is 2014-01-15:

 

altova:age(xs:date("2000-01-15"), xs:date("2010-01-15")) returns 10
altova:age(xs:date("2000-01-15"), current-date()) returns 14 if the current date is 2014-01-15
altova:age(xs:date("2014-01-15"), xs:date("2010-01-15")) returns -4

 

 

Click to expand/collapseage-details [altova:]

altova:age-details(InputDate as xs:date) as (xs:integer)*     XP3.1 XQ3.1

Returns three integers that are, respectively, the years, months, and days between the date that is submitted as the argument and the current date (taken from the system clock). The sum of the returned years+months+days together gives the total time difference between the two dates (the input date and the current date). The input date may have a value earlier or later than the current date, but whether the input date is earlier or later is not indicated by the sign of the return values; the return values are always positive.

If the current date is 2014-01-15:

 

altova:age-details(xs:date("2014-01-16")) returns (0 0 1)
altova:age-details(xs:date("2014-01-14")) returns (0 0 1)
altova:age-details(xs:date("2013-01-16")) returns (1 0 1)
altova:age-details(current-date()) returns (0 0 0)

 

altova:age-details(Date-1 as xs:dateDate-2 as xs:date) as (xs:integer)*     XP3.1 XQ3.1

Returns three integers that are, respectively, the years, months, and days between the two argument dates. The sum of the returned years+months+days together gives the total time difference between the two input dates; it does not matter whether the earlier or later of the two dates is submitted as the first argument. The return values do not indicate whether the input date occurs earlier or later than the current date. Return values are always positive.

altova:age-details(xs:date("2014-01-16"), xs:date("2014-01-15")) returns (0 0 1)
altova:age-details(xs:date("2014-01-15"), xs:date("2014-01-16")) returns (0 0 1)

 

 

[ Top ]

 


© 2019 Altova GmbH