Help | Site Map
Connecting Tech Pros Worldwide
 
 
LinkBack Thread Tools
  #1  
Old July 21st, 2006, 01:25 PM
martin.roclawski@cscworld.com
Guest
 
Posts: n/a
Default xsl date format

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?

  #2  
Old July 21st, 2006, 02:25 PM
Joe Kesselman
Guest
 
Posts: n/a
Default Re: xsl date format

martin.roclawski@cscworld.com wrote:
Quote:
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.
  #3  
Old July 21st, 2006, 03:05 PM
Martin Honnen
Guest
 
Posts: n/a
Default Re: xsl date format



martin.roclawski@cscworld.com wrote:
Quote:
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.


--

Martin Honnen
http://JavaScript.FAQTs.com/
 

Bookmarks


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are Off
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

What is Bytes?

We are a network of experts and professionals in IT and software development that help one another with answers to tough questions and share insights. Get the best answers to your questions from over network members.
Post your question now . . .
It's fast and it's free

Popular Articles