Date calculation Issue

Dear Sir

I create a page where users select two dates, now we want to display the gap between two days.

For example:

Appointment Date: "user select the calendar"   -Input 

Re leaving Date :" User Select the calendar- Input

Working Date: " Re leaving Date-Appointment Date"-should be populate  automatic. 

How and where we have to write the code??????

Please explain details. 

Regards

Nabin

 

  • simply calculate enddate-startdate. you get the number of days as result.

  • In reply to archer, MVP:

    Write code in OnValidate() trigger of the field in page. If these are table fields, you may write code OnValidate() trigger of fields in the table.

    For, Working Date = " Re leaving Date-Appointment Date", here goes the code,

    Re leaving Date - OnValidate()

    IF ("Re leaving Date" <> 0D) AND ("Appointment Date" <> 0D) THEN BEGIN

      IF ("Re leaving Date" > "Appointment Date") THEN

        "Working Date" := ("Re leaving Date" - "Appointment Date")

      ELSE

        ERROR('Re leaving Date must be greater than Appointment Date');

    END;

     

    Appointment Date - OnValidate()

    IF ("Re leaving Date" <> 0D) AND ("Appointment Date" <> 0D) THEN BEGIN

      IF ("Re leaving Date" > "Appointment Date") THEN

        "Working Date" := ("Re leaving Date" - "Appointment Date")

      ELSE

        ERROR('Re leaving Date must be greater than Appointment Date');

    END;

     

    Note that "Working Date" is not a date, it must be an integer for the above code to work. If you need your result as a date then some more code is required.

  • In reply to Ishwar Sharma:

    Hi Ishwar

    It is working bro....

     thank you.......From the bottom of my heart .

  • In reply to Nabin Sinha:

    Hi Nabin, You're welcome. :)

    Please verify the solution and don't forget to verify solutions in future as well whenever you get the solution to your issues in dynamicsuser.net

  • In reply to Ishwar Sharma:

    Problem Solved.

    Thanks Once again.

    Regards

    Nabin Kumar Sinha

     

Related