How I can minus two date/time fields and get results in third field

We want to get number of hrs in number by minus two date/time fields

Beginner Asked on February 4, 2021 in How To's.

What did you try? The obvious approach of getting both fields and subtracting them from each other and setting the result in another field should have gotten you very close to what you want

on February 5, 2021.
Add Comment
1 Answer(s)

You can test this out by just using the console in your browser.  The values of two NS date/time fields can be parsed by a javascript date object.  The result of subtracting two date objects comes out in milliseconds and you can divide to get the hours.


var testDate1 = new Date(); // for me this is Fri Feb 19 2021 09:10:50 GMT-0800 (Pacific Standard Time)
var testDate2 = new Date('2/18/2021'); //Thu Feb 18 2021 00:00:00 GMT-0800 (Pacific Standard Time)
var diff = testDate2 - testDate1; //119450971
var diffHrs = diff / 1000 / 60 /60; //33.18082527777778

Rookie Answered on February 19, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor