[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: Date comparasions

Subject: Re: Date comparasions
From: "Eric Bréchemier" <eric.brechemier@xxxxxxxxx>
Date: Thu, 6 Sep 2007 23:00:59 +0200
Re:  Date comparasions
  Hello Waqar,

this is a FAQ question, but still not so simple.
If you are using XSLT 2, you can refer to
http://www.dpawson.co.uk/xsl/rev2/dates.html#d16355e46

In your example, to test "IF HIRE IN LAST 60 DAYS", you would compute
- today
  current-date()

- a duration of 60 days
  xs:dayTimeDuration('P60D')
  with previous declaration of xmlns:xs="http://www.w3.org/2001/XMLSchema"

- remove 60 days from today
  current-date() - xs:dayTimeDuration('P60D')

- convert  <HIRE_DATE> to a date
  xs:date(HIRE_DATE)

- compare HIRE_DATE with today minus 60 Days using greater or equal (ge)
  xs:date(HIRE_DATE) ge ( current-date() - xs:dayTimeDuration('P60D')  )

I noticed that one date in your sample xml does not follow ISO format
(YYYY-MM-DD) since it lacks a leading '0' in '2007-09-1' so at this
step you may need a little more magic (or some manual editing before
running the transform).

Cheers,

Eric Brichemier

On 9/6/07, Waqar Ali wrote:
> The nature of the problem is that I need to do the date comparasions in the
> xsl.
>
> Any help with it will be greatly appreciated.
>
> Thanks.
> (...)
> > > >On 9/6/07, Waqar Ali wrote:
> > > > > Hi,
> > > > >
> > > > > XML:
> > > > > ====
> > > > > <EMP>
> > > > >         <ID>1</ID>
> > > > >         <TYPE>A</TYPE>
> > > > >         <HIRE_DATE>2007-05-20</HIRE_DATE>
> > > > > </EMP>
> > > > > <EMP>
> > > > >         <ID>2</ID>
> > > > >         <TYPE>B</TYPE>
> > > > >         <HIRE_DATE>2007-09-1</HIRE_DATE>
> > > > > </EMP>
> > > > > <EMP>
> > > > >         <ID>3</ID>
> > > > >         <TYPE>A</TYPE>
> > > > >         <HIRE_DATE>2007-08-20</HIRE_DATE>
> > > > > </EMP>
> > > > >
> > > > >
> > > > > LOGIC I NEED IN XSLT:
> > > > > ==============
> > > > > IF TYPE = A
> > > > >         IF HIRE IN LAST 60 DAYS
> > > > >                 'FULL_NEW'
> > > > >         ELSE
> > > > >                 'FULL'
> > > > > ELSE IF TYPE = B
> > > > >         'PART_TIME'
> > > > > ELSE
> > > > >         '-'
> > > > >
> > > > > Please help me out in this.
> > > > >
> > > > > Thanks,
> > > > > -Waqar

Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.