RE:VALIDATING TWO DATES

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

RE:VALIDATING TWO DATES

Reddy, Gopikrishna
HI IHAVE TWO DATE FIELDS IAM RESTRICTING THOSE TWO DATE FIELDS TO MM/DD/YYYY FORMAT AND MAKING THEM LESS THAN CURRENT DATE
 
NOW I NEED TO CHECK A CONDITION LIKE FIRST DATE MUST BE < 2ND DATE
AND 2ND DATE MUST BE GREATER THAN 1ST DATE
 
AND ALSO HOW CAN I CALCULATE THE DIFFERENCE BETWEEN TWO DATES IN DAYS
 
IAM GIVING THE CODE ,CAN ANYBODY PLEASE HELP AS THIS IS URGENT TO ME
 
THANKS IN ADVANCE ,
 
 
 
 
<xforms:bind nodeset="instance('main-instance')//giowndobdtdate1" type="xs:string"
    calculate="
            replace(
                instance('main-instance')//giowndobdt,
                '(\d{2})(/)(\d{2})(/)(\d{4})',
                '$5-$1-$3'
            )" />
    <xforms:bind nodeset="instance('main-instance')//giowndobdt"
    type="xs:string"
    constraint="if (.!='' and instance('main-instance')//status='1')
            then (
                if (instance('main-instance')//giowndobdtdate1 castable as xs:date)
                then (xs:date(instance('main-instance')//giowndobdtdate1) &lt; (current-date()))
                else false()
           ) else true()" />
 
 
 
<xforms:bind nodeset="instance('main-instance')//giownownchgdtdate2" type="xs:string"
    calculate="
            replace(
                instance('main-instance')//giownownchgdt,
                '(\d{2})(/)(\d{2})(/)(\d{4})',
                '$5-$1-$3'
            )" />
    <xforms:bind nodeset="instance('main-instance')//giownownchgdt"
    type="xs:string"
    constraint="if (.!='' and instance('main-instance')//status='1')
            then (
                if (instance('main-instance')//giownownchgdtdate2 castable as xs:date)
                then (xs:date(instance('main-instance')//giownownchgdtdate2) &lt; (current-date()))
                else false()
           ) else true()" />

 

REGARDS,

K GOPIKRISHNA REDDY


This e-mail (and any attachments), is confidential and may be privileged. It may be read, copied and used only
by intended recipients. Unauthorized access to this e-mail (or attachments) and disclosure or copying of its 
contents or any action taken in reliance on it is unlawful. Unintended recipients must notify the sender immediately 
by e-mail/phone & delete it from their system without making any copies or disclosing it to a third person.



--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws
Reply | Threaded
Open this post in threaded view
|

Re: RE:VALIDATING TWO DATES

fl.schmitt(ops-users)
Hi,

> *HI IHAVE TWO DATE FIELDS IAM RESTRICTING THOSE TWO DATE FIELDS TO
> MM/DD/YYYY FORMAT AND MAKING THEM LESS THAN CURRENT DATE *

> *NOW I NEED TO CHECK A CONDITION LIKE FIRST DATE MUST BE < 2ND DATE *
> *AND 2ND DATE MUST BE GREATER THAN 1ST DATE *

You can do this the same way as the current-date() comparison, i think:
your code

if (instance('main-instance')//giowndobdtdate1 castable as xs:date)
then  (
     xs:date(instance('main-instance')//giowndobdtdate1) &lt;
(current-date())
  ) else false()

could be transformed to

if (
     (instance('main-instance')//giowndobdtdate1 castable as xs:date)
     and
     (instance('main-instance')//date2 castable as xs:date)
) then  (
     (xs:date(instance('main-instance')//giowndobdtdate1 &lt;
current-date())
     and
     (xs:date(instance('main-instance')//giowndobdtdate1 &lt;
     instance('main-instance')//date2)
) else false()

and vice versa for date2. (i didn't test it...)

> *AND ALSO HOW CAN I CALCULATE THE DIFFERENCE BETWEEN TWO DATES IN DAYS*

there's a XPath function subtract-dates(date1, date2):
http://www.w3.org/TR/xpath-functions/#func-subtract-dates

HTH
florian




--
You receive this message as a subscriber of the [hidden email] mailing list.
To unsubscribe: mailto:[hidden email]
For general help: mailto:[hidden email]?subject=help
OW2 mailing lists service home page: http://www.ow2.org/wws