How do you convert a date in XSLT2.0?

176 views Asked by At

How can I format the resulted date below to display like this: MM/dd/YYYY (e.g.: 05/04/2020)?

The $getField will be: 2020-05-04T15:00:12

My value in the template is: <xsl:value-of select="xs:dateTime($getField)+xs:dayTimeDuration('PT1H')"/>

Currently, it displays as follows: 2020-04-05T16:00:12

Each time I try using format-date, I get an error. Also, if I will use xs:date(xs:dateTime($getField)+xs:dayTimeDuration('PT12H')), it will display only the date, without hours/minutes, but still not sure how can I change the order for date?

Thanks!

1

There are 1 answers

0
Mads Hansen On BEST ANSWER

Use the format-dateTime() function with the desired picture "[M01]/[D01]/[Y0001]":

format-dateTime(xs:dateTime($getField)+xs:dayTimeDuration('PT1H'), "[M01]/[D01]/[Y0001]")