XQuery current-date()
In XQuery, the fn:current-date()
function is used to retrieve the current date as an xs:date
value. This function does not take any arguments and returns the current date in the local time zone of the system on which the XQuery is executed.
The xs:date
data type represents a date value in the format “YYYY-MM-DD”, where “YYYY” is the year, “MM” is the month (01 to 12), and “DD” is the day (01 to 31).
Here’s an example of using fn:current-date()
in XQuery:
let $currentDate := fn:current-date()
return $currentDate
Output:
2023-07-27
In this example, the variable $currentDate
is assigned the current date when the XQuery is executed. The output will display the current date in the “YYYY-MM-DD” format.
Please note that the value returned by fn:current-date()
can vary depending on the system’s clock and time zone settings. If you need to obtain the current time or both date and time together, you can use the fn:current-time()
or fn:current-dateTime()
functions, respectively.