xsl date format

M

martin.roclawski

xsl newbie question: I don't seem to be able to find a simple function
to convert a date in DD/MM/YY format to an integer since Epoch. I have
the DD/MM/YY value in one mySQL database and trying to dump the data
into another database - the app that's using the second database
requires the date to be an integer.

Surely this is a fairly common requirement to transform dates to and
from the integer value?
 
J

Joe Kesselman

Surely this is a fairly common requirement to transform dates to and
from the integer value?

Common application requirement, but not a common stylesheet requirement,
so it isn't part of XSLT 1.0. (I'm not sure whether 2.0, which does more
with datatypes, adds it.)

Personally, I'd say it's time to investigate your XSLT processor's
support for extension functions. If you're using Xalan-J, for example,
it's not hard to invoke the Java date support. Downside is that
extension functions are nonportable (or, in the case of the EXSLT
semi-standard, only semi-portable) since they aren't part of the XSLT
standard.
 
M

Martin Honnen

xsl newbie question: I don't seem to be able to find a simple function
to convert a date in DD/MM/YY format to an integer since Epoch. I have
the DD/MM/YY value in one mySQL database and trying to dump the data
into another database - the app that's using the second database
requires the date to be an integer.

XSLT/XPath 1.0 does not have any date data type.

XSLT/XPath 2.0 uses the XSD schema types which have a format like
YYYY-MM-DD (plus the possibility for time zone information). There is a
substraction operator '-' defined on the date data type so you can do e.g.
xsd:date('2006-05-09') - xsd:date('1970-01-01')
which gives you a value of type duration from which you can extract the
number of days, hours, minutes, seconds with functions like
days-from-duration(xsd:date('2006-05-09') - xsd:date('1970-01-01'))
That way you can implement a function that converts the duration into
seconds.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top