xslt 2.0
I have xsd:dateTime field to which I have to assign current datetime formatted as
[D01]-[M01]-[Y0001] [h01]:[m01]:[s01] and using the below function
format-dateTime(current-dateTime(), '[D01]-[M01]-[Y0001] [h01]:[m01]:[s01]')
I am able to assign the above output to a xsd:string element and not to xsd:datetime element. I even tried of typecasting the same as xsd:dateTime(format-dateTime(current-dateTime(), '[D01]-[M01]-[Y0001] [h01]:[m01]:[s01]'))
but nothing works.. Any suggestions would be helpful
The format for the xs:dateTime
data type is defined as YYYY-MM-DDTHH:MM:SS
plus some timezone information. The format-dateTime
function returns a string in the format you specify but not a value of type xs:dateTime
. So what you want to do there is not possible, you can bind the result of current-dateTime()
to a variable of type xs:dateTime
, but certainly not the result of your format-dateTime(current-dateTime(), '[D01]-[M01]-[Y0001] [h01]:[m01]:[s01]')
expression, as that is a string in a format not representing an xs:dateTime
value.