xsl-list
[Top] [All Lists]

Re: Date Difference

2005-12-19 12:56:30
Do you have these functions written somewhere?




Tom Maciejewski
Société Générale
Information Technology
1221 Avenue of the Americas
New York, NY 10020
Tel. (212) 278-7103
Cell. (917) 690-9541


                                                                                
                                                     
                      David Carlisle                                            
                                                     
                      <davidc(_at_)nag(_dot_)co(_dot_)uk        To:       
xsl-list(_at_)lists(_dot_)mulberrytech(_dot_)com                                
             
                      >                        cc:                              
                                                     
                                               Subject:  Re: [xsl] Date 
Difference                                                   
                      12/19/2005 01:11                                          
                                                     
                      PM                                                        
                                                     
                      Please respond to                                         
                                                     
                      xsl-list                                                  
                                                     
                                                                                
                                                     
                                                                                
                                                     





I basically have two strings :   "9/11/2004"  and "10/25/2005"
and would like to produce the number of days between the two.

I didn't know there was a month 25.

and would like to produce the number of days between the two.

that's not too hard really, you just extract the year month and date
components using substring-before and substring after and then calculate
the number of days in each case (ignoring leap years) then correct for
leap years by comparing y mod 4 - y mod 100 + y mod 400 in each case.
(or y-1 if the actual date is in jan or feb)

  If that is too difficult it would be OK for me to know if one is equal
to
  the other ... or maybe if one is equal to, less than or greater than
the
  other.

exctract the three fields as above, format using format-number() so they
are two or four digits exactly then concatenate the fields as yyyymmdd
and compare the result as integers.

XSLT2 has date arithmetic built in but only if you have your dates in a
standard format such as 2005-10-25 so even with xslt2 you'd have to use
substring (or regexp-replace) originally to get your dates in a standard
form.

David

________________________________________________________________________
This e-mail has been scanned for all viruses by Star. The
service is powered by MessageLabs. For more information on a proactive
anti-virus service working around the clock, around the globe, visit:
http://www.star.net.uk
________________________________________________________________________

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



*************************************************************************
This message and any attachments (the "message") are confidential and
intended solely for the addressees.
Any unauthorised use or dissemination is prohibited. 
E-mails are susceptible to alteration.   
Neither SOCIETE GENERALE nor any of its subsidiaries or affiliates 
shall be liable for the message if altered, changed or falsified. 

*************************************************************************

--~------------------------------------------------------------------
XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list
To unsubscribe, go to: http://lists.mulberrytech.com/xsl-list/
or e-mail: <mailto:xsl-list-unsubscribe(_at_)lists(_dot_)mulberrytech(_dot_)com>
--~--



<Prev in Thread] Current Thread [Next in Thread>