How to get the difference between two date and time?
Good day!
I have created a form with the following fields:
- Start Date and Time (fieldname F01001 and F01002, respectively)
- Finish Date and Time (fieldname F02001 and F02002, respectively)
- Unbillable Hours (fieldname F03001)
All the dates have the format dd/mm/yyyy. Example: 01/09/ 2022 for September 1, 2022
All the times have the format hh:ss tt. Example: 2:30 for 2 hours and 30 second
What I want to happen is:
- First, validate if the Start Date and Time is less than Finish Date and Time. If valid, it should proceed to step b). Otherwise, it should displace a message to correct the data with an “OK” to exit from that message.
2. Then get the difference between the Start Date and Time and Finish Date and Time. Results should be the number of hours with 1 decimal place.
3. Subtract the Unbillable Hours from the Step 2 result.
Example:
Start Date and Time = 31/08/2022 10:00 pm
Finish Date and Time = 01/09/2022 06:30 am
Unbillable Hours = 2 hours
If I compute this manually, it would be 7.5 Hours less 2 unbillable hours equals 5.5 hours.
How do I do this?
If this cannot be done, I will be happy to have a solution if dates are not included. This means that the given are Start Time, Finish Date and Unbillable Hours.
Thank you in advance.
