1 Reply Latest reply on Aug 30, 2010 5:29 AM by pguerett

    Compare 2 dates - LC ES ver 8.2

    TST_HRMgr

      Hello,

       

      This may seem to be a very elementary questions but I am missing something that I have not been able to identify and am asking for anyone's assitance with this.

       

      In my form I am comparing two dates (<Date1> and <Date2>).  If <Date2> is less that <Date1> I would like to display a message box and then set the focus to <Date1>.

       

      I have tried numerous variations using Date2Num and .Rawvalue but the code seems to be skipping the IF THEN statement and goes directly to displaying the message.  On Exit from the <Date2> field the message box appears regardless if the date is less than, equal to, or greater than <Date1.

       

      Here is the code...

       

      topmostSubform.Page1.<Date2>::exit - (FormCalc, client)

      if

       

      (Date2Num(<Date2>,"DD-MMM-YY") < Date2Num(<Date1>,"DD-MMM-YY")) then

      xfa.host.messageBox("<<< CAUTION >>> Your <Date2> cannot be earlier than your <Date1>. Please correct your <Date1> date. Thank You")

      xfa.host.setFocus("<Date1>")

      Endif

       

      Thanks.

       

      TST