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
|