Subscribe Bookmark RSS Feed

Calculating difference between two dates and times in hours

fr2007

Community Trekker

Joined:

Jul 3, 2012

Iam trying to subtract two dates and times and get the answer in hours. For example

     Column1                   Column2

01/30/2013 5:30       02/02/2013   14:30

I want to subtract column1 from column2 and the difference in hours. I want to do this in JSL Scripting language... Can some one help how to subtract the above two dates..I mean the formula for doing that,.

Thanks a lot


1 ACCEPTED SOLUTION

Accepted Solutions
Solution

Same principle:

((:Column 4 + :Column 3) - (:Column 1 + :Column 2)) / 60 / 60

3 REPLIES
ms

Super User

Joined:

Jun 23, 2011

The date/time value internally represents nr of seconds since a reference date. Simply substract the the columns and divide with 3600 to get the result in hours.

(:Column2-Column1)/60/60

fr2007

Community Trekker

Joined:

Jul 3, 2012

But the Date is one column and Time is in another column. Sorry, I represented my data wrong in the above example. It actually looks like

  Column1           Column2               Column3                  Column4

01/30/2013              5:30                 02/02/2013              14:30

here column1 and column 2 is one set . Example, jan 30th 5:30 AM is represented by column 1 and column 2.

Feb 2nd 14:30 PM is represented by column 3 and column 4. Now I want to know how many hours are in between Feb 2nd 14:30 PM and Jan 30 5:30 AM.

Thanks,

Solution

Same principle:

((:Column 4 + :Column 3) - (:Column 1 + :Column 2)) / 60 / 60