AnsweredAssumed Answered

End Date Wrongly Calculated

Question asked by NaturSalus on Dec 18, 2012
Latest reply on Dec 19, 2012 by NaturSalus

Title

End Date Wrongly Calculated

Post

     Hello,

     I have a Trial Expiry script than on open from a lockdown state compares the Current date to the End date.

     When I set up the Start and End Trial dates the "unsafe" way, that is using Get (Current Date) to determine the Start date and from taht the End date, the script behaves as expected. 

     ...

      

     Else If [ IsEmpty ( zRESOURCES::gEndDate ) ]
      
     Set Field [ zRESOURCES::gEndDate; Get ( CurrentDate ) + 20 ]
      
     Set Field [ zRESOURCES::gStartDate; Get ( CurrentDate ) ]
      
     Show Custom Dialog [ Message: "This demo will expire in 20 days"; Buttons: “OK”, “Cancel” ]
     Exit Script [ ]

     ...

     However, when I set it up the "safe" way, that is the developer enters the Trial Start date in the ZRESOURCES::gTrialStartDate field and the Trial Expiry script contains the following script steps:

      

     ...
     Else If [ IsEmpty ( zRESOURCES::gEndDate ) ]
      
     Set Field [ zRESOURCES::gEndDate; zRESOURCES::gTrialStartDate + 20 ]
      
     Show Custom Dialog [ Message: "This demo will expire in 20 days"; Buttons: “OK”, “Cancel” ]
      
     Exit Script [ ]Set Field [ zRESOURCES::gStartDate; zRESOURCES::gTrialStartDate ]
     ...

      

      

     the generated End date makes no sense and on the second start up the user gets the messsage: "Trial period has expired"

     So for a zRESOURCES::gTrialStartDate of 18/12/2012 ( this is the date format on my machine under MS Windows 7 OS in Spain) the generated zRESOURCES::gEndDate is 20/01/0001

      

     Somehow the date format for Spain and for most European countries dd/mm/yyyy is misinterpreted by FM 11 when used in a calculation.

     Any clues how to sort it out so that I can use the "safe" way to set up Sart and End dates for the trial period of my runtime?

      

     Thanks,

      

     naturalsus

      

Outcomes