Skip to main content
Henry.Ong
Inspiring
September 1, 2022
Answered

How to get the difference between two date and time?

  • September 1, 2022
  • 1 reply
  • 5163 views

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:

  1. 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.

This topic has been closed for replies.
Correct answer bebarth

Hi Bebarth, 

 

Appreciate the effort you did here.

 

I downloaded Example_BB.pdf and when I tried it by entering the following:

 

Date = 02/09/2022

Start Time = 8:00 am

Finish Time = 6:00 pm

Unbillable Hours = 2

It gives me a message "The end time must be after the start time."

 

Also, is the script in Unbillable Hours under the Format tab, necessary? Can I delete that? Thanks.


A small error corrected!

You can remove the script of the Unbillable Hours field, but you will get an error if you enter a anything else than a number in this field.

@+

1 reply

Inspiring
September 1, 2022

This can be done, and there are a lot of dates time scripts on these forums try to research a bit and then post your solution, and we will help you.

Or if it's too much for you, you can always hire someone to do it for you.

Henry.Ong
Henry.OngAuthor
Inspiring
September 2, 2022

Hi Asim123,

 

Thank you for replying.

Before I posted my question, I tried to search here for a possible solution. The problem is zero knowledge about scripting. Apology for this.

I don't mind hiring someone (as you suggested) to provide the solution to my question. I just need to know you much would it cost me and how should I be paying.

Thank you..

bebarth
Community Expert
Community Expert
September 2, 2022

Hi,
Attached is an answer to your request.

Just a remark, in your example the result must be 6.5 hours and bot 7.5!

@+