Choose Language Hide Translation Bar
Highlighted
WHG
WHG
Occasional Contributor

How do I convert a timestamp to a duration format?

I would like to convert a column containing timestamp data in the numeric "ddMonyyyy h:m:s" time format to a numeric time duration format in seconds, starting the duration in the first row of my datatable.

0 Kudos
1 REPLY 1
ron_horne
Super User

Re: How do I convert a timestamp to a duration format?

Hi @WHG 

try the following script

otherwise you can do it manually using the same functions

names default to here (1);
dt = current data table ();
dt << New Column( "Duration",
		Numeric,
		"Continuous",
		Format( "Best", 12 ),
		Formula(
			Date Difference(
				:Date of Observation[1],
				:Date of Observation,
				"second"
			)
		)
	);

let us know if it works