cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Browse apps to extend the software in the new JMP Marketplace
Choose Language Hide Translation Bar
fr2007
Level II

Calculating difference between two dates and times in hours

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
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Calculating difference between two dates and times in hours

Same principle:

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

View solution in original post

3 REPLIES 3
ms
Super User (Alumni) ms
Super User (Alumni)

Re: Calculating difference between two dates and times in hours

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
Level II

Re: Calculating difference between two dates and times in hours

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,

ms
Super User (Alumni) ms
Super User (Alumni)

Re: Calculating difference between two dates and times in hours

Same principle:

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