![]() ![]() ![]() ![]() ![]() ![]() |
This chapter provides descriptions of the XQuery date functions available in the mapper functionality of WebLogic Workshop. You use the mapper functionality to generate queries and to edit these queries to add invocations to these provided XQuery functions. To learn more, see Invoking Functions or Operators in a Query.
In addition to the XQuery functions and operators available in the mapper functionality, a larger set functions and operators is provided. You can manually add invocations to these functions and operators to queries in the Source View of the mapper functionality. For a list of these additional functions and operators, see the XQuery 1.0 and XPath 2.0 Functions and Operators - W3C Working Draft 16 August 2002 available from the W3C Web site at the following URL:
http://www.w3.org/TR/2002/WD-xquery-operators-20020816
This section lists the date functions available from the mapper functionality:
Extracts the year from $dateTime-var
.
If the value of $dateTime-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
xf:
get-year-from-dateTime(
xs:
dateTime?$dateTime-var)
—> xs:
integer?
Returns the year as an integer from $dateTime-var
.
When you invoke the following query:
<year>{xf:get-year-from-dateTime("2002-08-30T22:21:01")}</year>
The preceding query generates the following result:
W3C get-year-from-dateTime function description.
W3C dateTime data type description.
Extracts the month from $dateTime-var
.
If the value of $dateTime-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xf:
get-month-from-dateTime(
xs:
dateTime? $dateTime-var)
—>xs:
integer?
Returns the month as an integer from $dateTime-var
.
When you invoke the following query:
<month>{xf:get-month-from-dateTime("2002-08-30T22:21:01")}</month>
The preceding query generates the following result:
W3C get-month-from-dateTime function description.
W3C dateTime data type description.
Extracts the day from $dateTime-var
.
If the value of $dateTime-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items (), which is similar to null in SQL.
xf:
get-day-from-dateTime(xs:
dateTime $dateTime-var)
—> xs:integer?
Returns the day as an integer from $dateTime-var
.
When you invoke the following query:
<day>{xf:get-day-from-dateTime("2002-08-30T22:21:01")}</day>
The preceding query generates the following result:
W3C get-day-from-dateTime function description.
W3C dateTime data type description.
Extracts the hours from $dateTime-var
.
If the value of $dateTime-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xf:
get-hours-from-dateTime(xs:
dateTime?$dateTime-var
) —> xs: integer?
Returns the hours as an integer from $dateTime-var
.
When you invoke the following query:
<hours>{xf:get-hours-from-dateTime("2002-08-30T22:21:01")}</hours>
The preceding query generates the following result:
The following example uses the get-hours-from-dateTime function with a timezone:
<hours>{xf:get-hours-from-dateTime("2002-08-30T14:21:01-05:00")}</hours>
The preceding query generates the following result:
In the preceding query, the -05:00
string specifies the time is specified in the Eastern Standard timezone which is 5
hours behind Coordinated Universal Time (UTC). The hours are reported in Coordinated Universal Time (UTC), so 5 hours are added to 14 hours of the Eastern Standard timezone, resulting in 19 hours in Coordinated Universal Time (UTC).
W3C get-hours-from-dateTime function description.
W3C dateTime data type description.
Extracts the minutes from $dateTime-var
.
If the value of $dateTime-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xf:
get-minutes-from-dateTime
(xs:
dateTime?$dateTime-var
) —> xs: integer?
Returns the minutes as an integer from $dateTime-var
.
When you invoke the following query:
<minutes>{xf:get-minutes-from-dateTime("2002-08-30T22:21:01")}</minutes>
The preceding query generates the following result:
W3C get-minutes-from-dateTime function description.
W3C dateTime data type description.
Extracts the seconds from $dateTime-var
.
If the value of $dateTime-var is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xf:
get-seconds-from-dateTime
(xs:
dateTime? $dateTime-var) —> xs:xs:
decimal?
Returns the seconds as an decimal from $dateTime-var
.
When you invoke the following query:
<seconds>{xf:get-seconds-from-dateTime("2002-08-30T22:21:01")}</seconds>
The preceding query generates the following result:
W3C get-seconds-from-dateTime function description.
W3C dateTime data type description.
Extracts the current timezone from $dateTime-var
and returns it as a string.
If $dateTime-var
does not contain a timezone, the empty sequence is returned.
If the value of $dateTime-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xf:
get-timezone-from-dateTime(xs:
dateTime? $dateTime-var)
—> xs:
string ?
Returns the current timezone as a string from $dateTime-var
.
Returns an empty sequence, if $dateTime-var
does not contain a timezone. (See examples below.)
The following example uses the get-timezone-from-dateTime function with a timezone:
<tz>{xf:get-timezone-from-dateTime("2002-08-30T14:21:01-05:00")}</tz>
The preceding query generates the following result:
In the preceding query, the -05:00 string specifies the time is specified in the Eastern Standard time zone which is 5 hours behind Universal Time, Coordinated (UTC).
The following example uses the get-timezone-from-dateTime function with a timezone:
<tz>{xf:get-timezone-from-dateTime("2002-08-30T14:21:01Z")}</tz>
The preceding query generates the following result:
In this example, the Z
means the time is being specified in Universal Coordinated, Time (UTC), so no timezone is reported.
The following is an example of using the get-timezone-from-dateTime function with no timezone specified:
<tz>{xf:get-timezone-from-dateTime("2002-08-30T22:21:01")}</tz>
The preceding query generates the following result:
W3C get-timezone-from-dateTime function description.
W3C dateTime data type description.
Extracts the year from $date-var
.
If the value of $date-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xf:
get-year-from-date(xs:
date?
$date-var)
—> xs: integer?
Returns the year as an integer from $date-var
.
When you invoke the following query:
<year>{xf:get-year-from-date("2002-08-30")}</year>
The preceding query generates the following result:
W3C get-year-from-date function description.
W3C date data type description.
Extracts the month from $date-var.
If the value of $date-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xf:
get-month-from-date(xs:
date? $date-var)
—> xs: integer?
Returns the month as an integer from $date-var
.
When you invoke the following query:
<month>{get-month-from-date("2002-08-30")}</month>
The preceding query generates the following result:
W3C get-month-from-date function description.
W3C date data type description.
Extracts the day from $date-var
.
If the value of $date-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xf:
get-day-from-date
(xs:
date? $date-var
) —>xs: integer?
Returns the day as an integer from $date-var
.
When you invoke the following query:
<day>{xf:get-day-from-date("2002-08-30")}</day>
The preceding query generates the following result:
W3C get-day-from-date function description.
W3C date data type description.
Extracts the current timezone from $date-var
.
If $date-var
does not contain a timezone, the empty sequence is returned.
If the value of $date-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xf:
get-timezone-from-date(xs:
date?$date-var)
—>xs:
string ?
Returns the current timezone as a string from $date-var
.
Returns an empty sequence, if $date-var
does not contain a timezone. (See examples below.)
The following example uses the get-timezone-from-date function with a timezone:
<tz>{xf:get-timezone-from-date(xs:date("2002-08-30-05:00"))}</tz>
The preceding query generates the following result:
In the preceding query, the -05:00
string specifies the time is specified in the Eastern Standard timezone which is 5
hours behind Coordinated Universal Time (UTC).
The following example uses the get-timezone-from-date function with a timezone:
<tz>{xf:get-timezone-from-date(xs:date("2002-08-30Z"))}</tz>
The preceding query generates the following result:
In this preceding query, the Z
means the time is being specified in Coordinated Universal Time (UTC), so no timezone is reported.
The following is an example of using the get-timezone-from-date function with no timezone specified:
<tz>{xf:get-timezone-from-date(xs:date("2002-08-30"))}</tz>
The preceding query generates the following result:
W3C get-timezone-from-date function description.
W3C date data type description.
Extracts the hours from $time-var
.
If the value of $time-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xf:
get-hours-from-time(xs:
time? $time-var)
—>xs: integer?
Returns the hours as an integer from $time-var
.
The following is a simple example using the get-hours-from-time function:
<hours>{xf:get-hours-from-time("22:21:01")}</hours>
The preceding query generates the following result:
The following example uses the get-hours-from-time function with a timezone:
<hours>{xf:get-hours-from-time("14:21:01-05:00")}</hours>
The preceding query generates the following result:
In the preceding query, the -05:00
string specifies the time is specified in the Eastern Standard timezone which is 5
hours behind Coordinated Universal Time (UTC). The hours are reported in Coordinated Universal Time (UTC), so 5
hours are added to 14
hours of the Eastern Standard timezone, resulting in 19
hours in Coordinated Universal Time (UTC).
W3C get-hours-from-time function description.
W3C time data type description.
Extracts the minutes from $time-var
.
If the value of $time-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xf:
get-minutes-from-time(xs:
time? $time-var
) —> xs: integer?
Returns the minutes as an integer from $time-var
.
The following is a simple example using the get-minutes-from-time function:
<minutes>{xf:get-minutes-from-time("22:21:01")}</minutes>
The preceding query generates the following result:
The following example uses the get-minutes-from-time function with a timezone:
<minutes>{xf:get-minutes-from-time("14:21:01-05:00")}</minutes>
The preceding query generates the following result:
W3C get-minutes-from-time function description.
W3C time data type description.
Extracts the seconds from $time-var
.
If the value of $time-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xf:
get-seconds-from-time(xs:
time?$time-var)
—> xs:
decimal ?
Returns the seconds as an decimal from $time-var
.
The following is a simple example using the get-seconds-from-time function:
<seconds>{xf:get-seconds-from-time("22:21:01")}</seconds>
The preceding query generates the following result:
The following example uses the get-seconds-from-time function with a timezone:
<seconds>{xf:get-seconds-from-time("14:21:01-05:00")}</seconds>
The preceding query generates the following result:
W3C get-seconds-from-time function description.
W3C time data type description.
Extracts the current timezone from $time-var
.
If $time-var
does not contain a timezone, the empty sequence is returned.
If the value of $time-var
is the empty sequence, the empty sequence is returned. The empty sequence is a sequence containing zero items ()
, which is similar to null in SQL.
xf:
get-timezone-from-time(xs:
time? $time-var)
—>xs:
string ?
Returns the current timezone as a string from $time-var
.
Returns an empty sequence, if $time-var
does not contain a timezone. (See examples below.)
The following example uses the get-timezone-from-time function with a timezone:
<tz>{xf:get-timezone-from-time(xs:time("14:21:01-05:00"))}</tz>
The preceding query generates the following result:
In the preceding query, the -05:00
string specifies the time is specified in the Eastern Standard timezone which is 5
hours behind Coordinated Universal Time (UTC).
The following example uses the get-timezone-from-time function with a timezone:
<tz>{get-timezone-from-time(xs:time("14:21:01Z"))}</tz>
The preceding query generates the following result:
In this preceding query, the Z
means the time is being specified in Coordinated Universal Time (UTC), so no timezone is reported.
The following is an example of using the get-timezone-from-time function with no timezone specified:
<tz>{xf:get-timezone-from-time(xs:time("22:21:01"))}</tz>
Returns an empty sequence, because $time-var does not contain a timezone.
W3C get-timezone-from-time function description.
W3C time data type description.
Adds a time zone to a
dateTime value. The timezone added to the date Time value is either the implicit time zone or passed in with the optional argument: $dayTimeDuration-var
.
Note: | The implicit time zone is obtained from the current environment. For example, if the time zone specified on your machine is the PSD (Pacific Daylight Savings), the implicit time zone would be -07:00. |
Adds a time zone to a date Timevalue by invoking the following steps:
$dateTime-var)
will have not have a time zone, so this step will be ignored as shown in the preceding examples. $dayTimeDuration-var
or the implicit time, to the date Time value (argument: $dateTime-var
).
xf:
add-timezone-to-dateTime(
xs:
dateTime $dateTime-var) —>xs: date Time
xf:add-timezone-to-dateTime(xs: date Time $dateTime-var, xf:
dayTimeDuration, $dayTimeDuration-var) —> xs: date Time
Returns a date Time with a time zone.
If $dateTime-var
contains a time zone and the optional argument $dayTimeDuration-var
is not specified, the passed in date and time are returned with no conversion.
The following example adds the specified time zone to the specified date Time value. In this example, the specified date Time value: 2002-12-06T12:00:00, initially does not have a timezone zone associated with it.
Adding the specified time zone to the specified date Time value, by invoking xf:add-timezone-to-dateTime(xs:dateTime("2002-12-06T12:00:00", dayTimeDuration("-PT7H"))), causes the following internal conversion steps:
let $dateTimeWithNoTimezone := xs:dateTime("2002-12-06T12:00:00")
<dateTimeWithNoTimezone>{$dateTimeWithNoTimezone}</dateTimeWithNoTimezone>
<dateTimeWithTimeZoneAdded>{ xf:add-timezone-to-dateTime(xs:dateTime($dateTimeWithNoTimezone),
xf:dayTimeDuration("-PT7H")) }</dateTimeWithTimeZoneAdded>
The preceding query produces the following result:
<dateTimeWithNoTimezone>2002-12-06T12:00:00</dateTimeWithNoTimezone>
<dateTimeWithTimeZoneAdded>2002-12-06T19:00:00Z</dateTimeWithTimeZoneAdded>
Note: | The Z at the end of the 2002-12-06T19:00:00Z value specifies that the dateTime value is in UTC time. |
The following example adds the implicit time zone to the specified date Time value. In this example, the specified date Time value: 2002-12-06T12:00:00
, initially does not have a timezone zone associated with it.
In this example, the implicit time zone is assumed to be -07:00
, the Pacific Daylight Savings Time (PST) time zone. (The implicit time zone is the default time zone for the current machine.)
Adding the implicit time zone to the specified date Time value, by invoking xf:add-timezone-to-dateTime(xs:dateTime("2002-12-06T12:00:00")), causes the following internal conversion steps:
let $dateTimeWithNoTimezone := xs:dateTime("2002-12-06T12:00:00")
<dateTimeWithNoTimezone>{$dateTimeWithNoTimezone}</dateTimeWithNoTimezone>
<dateTimeWithTimeZoneAdded>{ xf:add-timezone-to-dateTime(xs:dateTime($dateTimeWithNoTimezone)) }
The preceding query produces the following result:
<dateTimeWithNoTimezone>2002-12-06T12:00:00</dateTimeWithNoTimezone>
<dateTimeWithTimeZoneAdded>2002-12-06T19:00:00Z</dateTimeWithTimeZoneAdded>
Note: | The Z at the end of the 2002-12-06T19:00:00Z value specifies that the dateTime value is in UTC time. |
Note: | The results of this query maybe be different for your machine because the implicit time zone may be different. |
W3C add-timezone-to-dateTime function description.
W3C dateTime data type description.
W3C dayTimeDuration operator description.
Removes a time zone from a dateTime value. The
dateTime value with a time zone is localized to either the implicit time zone or to time zone specified by the argument: $dayTimeDuration-var
and then the timezone indicator is removed.
If the specified dateTime
value has no time zone associated with it, then the implicit time zone is added to dateTime value before the localization described above is done. Since the purpose of the remove-timezone-to-dateTime
function is to remove a timezone from a dateTime value with a timezone, in most cases the passed in dateTime value (argument: $dateTime-var)
will have a time zone, so this step will be ignored as shown in the preceding examples.
Note: | The implicit time zone is obtained from the current environment. For example, if the time zone specified on your machine is the PSD (Pacific Daylight Savings), the implicit time zone would be -07:00 . |
xf:
remove-timezone-from-dateTime(
xs:
dateTime $dateTime-var) —> xs: dateTime
xf:remove-timezone-from-dateTime(xs: dateTime $dateTime-var, xf:
dayTimeDuration, $dayTimeDuration-var) —> xs: dateTim
e
Returns a dateTime without a time zone.
If $dateTime-var
does not contain a time zone and optional argument $dayTimeDuration-var
is not specified, the passed in date and time are returned with no conversion.
The following example removes the specified time zone from the specified dateTime value.
In this example, the passed in
dateTime value: 2002-12-06T12:00:00Z is specified with the UTC time zone specified by the time zone indicator: Z
.
The time zone is specified with the
dayTimeDuration string: -PT7H
, in the preceding query which is the Pacific Daylight Savings Time (PST) time zone (-07:00).
The passed in dateTime value: 2002-12-06T12:00:00Z specified with the UTC time zone is localized to PST time zone and the time zone indicator (Z
) is removed, as shown in the following example query:
let $dateTimeWithUTCTimezone := xs:dateTime("2002-12-06T12:00:00Z")
<dateTimeWithUTCTimezone>{$dateTimeWithUTCTimezone}</dateTimeWithUTCTimezone>
<dateTimeWithTimeZoneAdded>{ xf:remove-timezone-from-dateTime(xs:dateTime($dateTimeWithUTCTimezone,
xf:dayTimeDuration("-PT7H"))) }</dateTimeWithTimeZoneAdded>
The preceding query produces the following result:
<dateTimeWithUTCTimezone>2002-12-06T12:00:00Z</dateTimeWithUTCTimezone>
<dateTimeWithTimeZoneAdded>2002-12-06T05:00:00</dateTimeWithTimeZoneAdded>
The following example removes the implicit time zone from the specified
dateTime value. In this example, the passed in dateTime value: 2002-12-06T12:00:00Z is specified with the UTC time zone specified by the time zone indicator: Z
.
In this example, the implicit time zone is assumed to be -07:00
, the Pacific Daylight Savings Time (PST) time zone. (The implicit time zone is the default time zone for the current machine.)
The passed in dateTime value: 2002-12-06T12:00:00Z specified with the UTC time zone is localized to PST time zone and the time zone indicator (Z
) is removed, as shown in the following example query:
let $dateTimeWithUTCTimezone := xs:dateTime("2002-12-06T12:00:00Z")
<dateTimeWithUTCTimezone>{$dateTimeWithUTCTimezone}</dateTimeWithUTCTimezone>
<dateTimeWithTimeZoneAdded>{ xf:remove-timezone-from-dateTime(xs:dateTime($dateTimeWithUTCTimezone)) }
The preceding query produces the following result:
<dateTimeWithUTCTimezone>2002-12-06T12:00:00Z</dateTimeWithUTCTimezone>
<dateTimeWithTimeZoneAdded>2002-12-06T05:00:00</dateTimeWithTimeZoneAdded>
W3C remove-timezone-from-dateTime function description.
W3C dateTime data type description.
W3C dayTimeDuration operator description.
Adds a time zone to a
date value. The timezone added to the date value is either the implicit time zone or passed in with the optional argument: $dayTimeDuration-var
.
Note: | The implicit time zone is obtained from the current environment. For example, if the time zone specified on your machine is the PSD (Pacific Daylight Savings), the implicit time zone would be -07:00 . |
Adds a time zone to a date value by invoking the following steps:
If the specified date value already has a time zone value, that time zone is removed from the date value. Since the purpose of the add-timezone-to-date function is to add a timezone to a date value without a timezone, in most cases the passed in date value (argument: $date-var
) will have not have a time zone, so this step will be ignored as shown in the preceding examples.
Adds the time zone, specified by either the optional argument $dayTimeDuration-var or the implicit time, to the date value (argument: $date-var
).
Converts the new date value generated by the previous step to a Universal Coordinated Time (UTC) time zone value.
xf:add-timezone-to-date(
xs:
date $date-var) —>xs: date
xf:
add-timezone-to-date(xs: date $date-var,
xf:
dayTimeDuration $dayTimeDuration-var) —> xs: date
Returns a date with a time zone.
If $date-var
contains a time zone and optional argument $dayTimeDuration-var
is not specified, the passed in date and time are returned with no conversion.
The following example adds the specified time zone to the specified date value. In this example, the specified date value: 2002-12-06, initially does not have a timezone zone associated with it.
Adding the specified time zone to the specified date value, by invoking xf:add-timezone-to-date(xs:date("2002-12-06", dayTimeDuration("-PT7H"))), causes the following internal conversion steps:
let $dateWithNoTimezone := xs:date("2002-12-06")
<dateWithNoTimezone>{$dateWithNoTimezone}</dateWithNoTimezone>
<dateWithTimeZoneAdded>{ xf:add-timezone-to-date(xs:date($dateWithNoTimezone),
xf:dayTimeDuration("-PT7H")) }</dateWithTimeZoneAdded>
The preceding query produces the following result:
<dateWithNoTimezone>2002-12-06</dateWithNoTimezone>
<dateWithTimeZoneAdded>2002-12-06Z</dateWithTimeZoneAdded>
Note: | The Z at the end of the 2002-12-06Z value specifies that the date value is in UTC time. |
The following example adds the implicit time zone to the specified date value. In this example, the specified date value: 2002-12-06, initially does not have a timezone zone associated with it.
In this example, the implicit time zone is assumed to be -07:00, the Pacific Daylight Savings Time (PST) time zone. (The implicit time zone is the default time zone for the current machine.)
Adding the implicit time zone to the specified date value, by invoking xf:add-timezone-to-date(xs:date("2002-12-06")), causes the following internal conversion steps:
let $dateWithNoTimezone := xs:date("2002-12-06")
<dateWithNoTimezone>{$dateWithNoTimezone}</dateWithNoTimezone>
<dateWithTimeZoneAdded>{ xf:add-timezone-to-date(xs:date($dateWithNoTimezone)) }
The preceding query produces the following result:
<dateWithNoTimezone>2002-12-06</dateWithNoTimezone>
<dateWithTimeZoneAdded>2002-12-06Z</dateWithTimeZoneAdded>
Note: | The Z at the end of the 2002-12-06Z value specifies that the date value is in UTC time. |
Note: | The results of this query maybe be different for your machine because the implicit time zone may be different. |
W3C add-timezone-to-date function description.
W3C date data type description.
W3C dayTimeDuration operator description.
Adds a time zone to a
time value. The timezone added to the time value is either the implicit time zone or passed in with the optional argument: $dayTimeDuration-var
.
Note: | The implicit time zone is obtained from the current environment. For example, if the time zone specified on your machine is the PSD (Pacific Daylight Savings), the implicit time zone would be -07:00. |
Adds a time zone to a time value by invoking the following steps:
add-timezone-to-time
function is to add a timezone to a time value without a timezone, in most cases the passed in time value (argument: $time-var
) will have not have a time zone, so this step will be ignored as shown in the preceding examples. $dayTimeDuration-var
or the implicit time, to the timevalue (argument: $time-var
).
xf:
add-timezone-to-time(
xs:
time $time-var) —>xs: time
xf:add-timezone-to-time(xs: time $time-var,
xf:
dayTimeDuration, $dayTimeDuration-var) —> xs: time
Returns a time with a time zone.
If $time-var
contains a time zone and optional argument $dayTimeDuration-var
is not specified, the passed in date and time are returned with no conversion.
The following example adds the specified time zone to the specified time value. In this example, the specified time value: 12:00:00, initially does not have a timezone zone associated with it.
Adding the specified time zone to the specified time value, by invoking xf:date-timezone-to-time(xs:time("12:00:00", dayTimeDuration("-PT7H"))), causes the following internal conversion steps:
In this example, the time zone is specified with the day Time Duration string: -PT7H, which is the Pacific Daylight Savings Time (PST) time zone (-07:00). This specified time zone: -07:00 is added to the specified time value: 12:00:00 resulting in the following internal time value: 12:00:00-07:00.
This new time value: 19:00:00-07:00 is converted to Universal Coordinated Time (UTC), resulting in the following time value: 19:00:00Z, as shown in the following example query:
let $timeWithNoTimezone := xs:time("12:00:00")
<timeWithNoTimezone>{$timeWithNoTimezone}</timeWithNoTimezone>
<timeWithTimeZoneAdded>{ xf:add-timezone-to-time(xs:time($timeWithNoTimezone)
,
xf:dayTimeDuration("-PT7H")) }</timeWithTimeZoneAdded>
The preceding query produces the following result:
<timeWithNoTimezone>12:00:00</timeWithNoTimezone>
<timeWithTimeZoneAdded>19:00:00Z</timeWithTimeZoneAdded>
Note: | The Z at the end of the 19:00:00Z value specifies that the time value is in UTC time. |
The following example adds the implicit time zone to the specified time value. In this example, the specified time value: 12:00:00, initially does not have a timezone zone associated with it.
In this example, the implicit time zone is assumed to be -07:00, the Pacific Daylight Savings Time (PST) time zone. (The implicit time zone is the default time zone for the current machine.)
Adding the implicit time zone to the specified time value, by invoking xf:add-timezone-to-time(xs:time("12:00:00")), causes the following internal conversion steps:
The implicit time zone: -07:00 is added to the specified time value: 12:00:00 resulting in the following internal time value: 12:00:00-07:00.
This new time value: 19:00:00-07:00 is converted to Universal Coordinated Time (UTC), resulting in the following time value: 19:00:00Z, as shown in the following example query:
let $timeWithNoTimezone := xs:time("12:00:00")
<timeWithNoTimezone>{$timeWithNoTimezone}</timeWithNoTimezone>
<timeWithTimeZoneAdded>{ xf:add-timezone-to-time(xs:time($timeWithNoTimezone)) }
The preceding query produces the following result:
<timeWithNoTimezone>12:00:00</timeWithNoTimezone>
<timeWithTimeZoneAdded>19:00:00Z</timeWithTimeZoneAdded>
Note: | The Z at the end of the 19:00:00Z value specifies that the time value is in UTC time. |
Note: | The results of this query maybe be different for your machine because the implicit time zone may be different. |
W3C add-timezone-to-time function description.
W3C time data type description.
W3C dayTimeDuration operator description.
Removes a time zone from a
time value. The time value with a time zone is localized to either the implicit time zone or to time zone specified by the argument: $dayTimeDuration-var
and then the timezone indicator is removed.
If the specified time value has no time zone associated with it, then the implicit time zone is added to time value before the localization described above is done. Since the purpose of the remove-timezone-to-time
function is to remove a timezone from a time value with a timezone, in most cases the passed in time value (argument: $time-var
) will have a time zone, so this step will be ignored as shown in the following examples.
Note: | The implicit time zone is obtained from the current environment. For example, if the time zone specified on your machine is the PSD (Pacific Daylight Savings), the implicit time zone would be -07:00. |
xf:
remove-timezone-from-time(
xs:
time$time-var) —>xs: time
xf:remove-timezone-from-time(xs: time $time-var
, xf:
dayTimeDuration, $dayTimeDuration-var) —> xs: time
Returns a time without a time zone.
If $time-var
does not contain a time zone and optional argument $dayTimeDuration-var
is not specified, the passed in time is returned with no conversion.
The following example removes the specified time zone from the specified time value.
In this example, the passed in time value: 12:00:00Z is specified with the UTC time zone as specified by the time zone indicator: Z
.
The time zone is specified with the day Time Duration string: -PT7H, in the preceding query which is the Pacific Daylight Savings Time (PST) time zone (-07:00).
The passed in time value: 12:00:00Z specified with the UTC time zone is localized to PST time zone and the time zone indicator (Z) is removed, as shown in the following example query:
let $timeWithUTCTimezone := xs:time("12:00:00Z")
<timeWithUTCTimezone>{$timeWithUTCTimezone}</timeWithUTCTimezone>
<timeWithTimeZoneAdded>{ xf:remove-timezone-from-time(xs:time($timeWithUTCTimezone),
xf:dayTimeDuration("-PT7H")) }</timeWithTimeZoneAdded>
The preceding query produces the following result:
<timeWithUTCTimezone>12:00:00Z</timeWithUTCTimezone>
<timeWithTimeZoneAdded>05:00:00</timeWithTimeZoneAdded>
The following example removes the implicit time zone from the specified time
value. In this example, the passed in time value: 12:00:00Z is specified with the UTC time zone as specified by the time zone indicator: Z
.
In this example, the implicit time zone is assumed to be -07:00, the Pacific Daylight Savings Time (PST) time zone. (The implicit time zone is the default time zone for the current machine.)
The passed in time value: 12:00:00Z specified with the UTC time zone is localized to PST time zone and the time zone indicator (Z
) is removed, as shown in the following example query:
let $timeWithUTCTimezone := xs:time("12:00:00Z")
<timeWithUTCTimezone>{$timeWithUTCTimezone}</timeWithUTCTimezone>
<timeWithTimeZoneAdded>{ xf:remove-timezone-from-time(xs:time($timeWithUTCTimezone)) }
The preceding query produces the following result:
<timeWithUTCTimezone>12:00:00Z</timeWithUTCTimezone>
<timeWithTimeZoneAdded>05:00:00</timeWithTimeZoneAdded>
W3C remove-timezone-from-time function description.
W3C time data type description.
W3C dayTimeDuration operator description.
Gets the current date and time.
xf:
current-dateTime() —>
xs:
dateTime?
Returns the current date and time as a date Time value.
All invocations of this function in a single outermost XQuery or XPATH expression will report the same date and time.
The following simple example query, calls the current-dateTime
function a single time:
<current>{xf:current-dateTime()}</current>
If the current date is November 11, 2002 and the current time is 4:23, the preceding XQuery generates the following result:
<current>2002-11-11T04:23:14.9030000</current>
The following example query, invokes the current-dateTime function twice:
<first>{xf:current-dateTime()}</first>
<second>{xf:current-dateTime()}</second>
If the current date is November 11, 2002 and the current time is 4:23, the preceding XQuery generates the following result:
<first>2002-11-11T04:23:34.5430000</first>
<second>2002-11-11T04:23:34.5430000</second>
Note: | The same exact time (even seconds) is returned for both invocations of the function. |
W3C current-dateTime function description.
W3C dateTime data type description.
xf:
current-date() —>
xs:
date?
Returns the current date as a date value.
All invocation of this function in a single outermost XQuery or XPATH expression will report the same date.
The following example query, invokes the current-date function:
<current>{xf:current-date()}</current>
If the current date is November 11, 2002 and the current time is 4:23, The preceding query generates the following result:
W3C current-date function description.
W3C date data type description.
Returns the current date and time as a time value.
All invocation of this function in a single outermost XQuery or XPATH expression will report the same time.
The following example query, invokes the current-time function a single time:
<current>{xf:current-time()}</current>
If the current date is November 11, 2002 and the current time is 4:23, The preceding query generates the following result:
<current>04:23:14.9030000</current>
The following example query, invokes the current-time function twice:
<first>{xf:current-time()}</first>
<second>{xf:current-time()}</second>
If the current date is November 11, 2002 and the current time is 4:23, The preceding query generates the following result:
<first>04:23:34.5430000</first>
<second>04:23:34.5430000</second>
Note: | The same exact time (even seconds) is returned for both invocations of the function. |
W3C current-time function description.
W3C time data type description.
![]() ![]() ![]() |