Subject: Re: [xsl] Date Difference From: David Carlisle <davidc@xxxxxxxxx> Date: Mon, 19 Dec 2005 18:11:43 GMT |
> 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 ________________________________________________________________________
Current Thread |
---|
|
<- Previous | Index | Next -> |
---|---|---|
[xsl] Date Difference, thomas . maciejewski | Thread | Re: [xsl] Date Difference, andrew welch |
[xsl] Date Difference, thomas . maciejewski | Date | Re: [xsl] Date Difference, andrew welch |
Month |