Sunday, February 13, 2011

Comparing Dates in XSLT

Dates manipulation is a very daunting task in XSLT, considering the very limited date-time functions that XSLT 1.0 offers. XSLT 2.0 is enhanced as far this case is concerned. I had to compare dates in XSLT 1.0 and I was contemplating of using a java embedding node, not until I found how to compare the dates in XSLT as below:

1. Convert the date into the format YYYY-MM-DD, either using a function or using existing string functions
2. Do a translate on the date available, translate($Date, '-', '')
3. By doing a translate, the date is converted to ISO date format
4. Do this to both the dates
5. The dates in the ISO format can be directly used for comparison like ISODate1 > ISODate2 etc


Cheers,
-AR

5 comments:

Anonymous said...

Thanks.Very helpful!

Unknown said...

nice and helpful
Oracle Training in Chennai

Anonymous said...

Your blog is really useful for me. Thanks for sharing this informative blog. If anyone wants to get real time Oracle Training Chennai reach FITA Oracle Training Center in Chennai. They give professional and job oriented training for all students.

Unknown said...

thanks.......

Oracle Training

Unknown said...

Hi friends, This is Jamuna from Chennai. Your technical information is really useful for me. Keep update your blog.
Regards..
Oracle Training

Creative Commons License
This work is licensed under a Creative Commons Attribution-Noncommercial-No Derivative Works 3.0 Unported License