cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • We’re improving the Learn JMP page, and want your feedback! Take the survey
  • JMP monthly Newswire gives user tips and learning events. Subscribe
Choose Language Hide Translation Bar
babn
Level II

Creating an Time elapsed column from a datetime column

Hi All,

 

Help with this would be greatly appreciated. I am trying to create a new column that generates the elapsed time in hours from a column that has date/time in the following format, "04/22/2025 11:16 AM."

 

Thanks!

Barbara

2 REPLIES 2
babn
Level II

Re: Creating an Time elapsed column from a datetime column

Found a solution that works!

jthi
Super User

Re: Creating an Time elapsed column from a datetime column

Could you post your solution? If you have your data correctly formatted as date in JMP the difference will be in seconds and you can convert it to hours dividing it by 3600 or In Hours(1) or just change the format to Duration this might be unnecessary (generally I would try to keep the values as seconds and play around with formats, but this varies case by case). Below is example in a form of JSL

Names Default To Here(1);

dt = New Table("demo",
	Add Rows(4),
	Compress File When Saved(1),
	New Column("Times",
		Numeric,
		"Continuous",
		Format("ddMonyyyy h:m:s", 22, 0),
		Input Format("ddMonyyyy h:m:s", 0),
		Set Values([3830699241, 3830702820, 3830710041, 3830882841])
	)
);

dt << New Column("Dif", Numeric, Continuous, Format("hr:m:s", 13, 0), Set Property("Units", "hr:m:s"), Formula(
	Dif(:Times)
));

jthi_0-1747844101274.png

For more complicated comparisons you can use Date Difference(), in this case it would look something like this (note that the intervalName is "hour" and not "second" in this example)

Date Difference(
	Lag(:Times),
	:Times,
	"hour",
	"fractional"
);
-Jarmo

Recommended Articles