cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Check out the JMP® Marketplace featured Capability Explorer add-in
Choose Language Hide Translation Bar
shasheminassab
Level IV

Convert time from character to continous

I have a "Time" column in my dataset and am attempting to convert it to Continuous data type. I am using the "Set Format Pattern" in JMP 16 and everything looks OK except for the timestamps at midnight. This is because the midnight time (00:00:00) in the original dataset is missing. See the attached picture. Any suggestions on how to fix it?

Time Conversion.png

1 ACCEPTED SOLUTION

Accepted Solutions
txnelson
Super User

Re: Convert time from character to continous

@shasheminassab 

I would just pass through the Time(Character) column and add " 00:00:00" if the hours, minutes, seconds do not appear

 

Something like this should work

Names Default To Here( 1 );
dt = Current Data Table();

For Each Row(
	If( Contains( :"Time(Character)"n, ":" ) == 0,
		:"Time(Character)"n = :"Time(Character)"n || " 00:00:00"
	)
);

 

Jim

View solution in original post

5 REPLIES 5
aliegner1
Level IV

Re: Convert time from character to continous

not an answer, but I came here to post something very similar

 

I've got a date timestamp coming in as Character>Nominal in this wierd timezone format that I can't figure out how to convert to a proper date-timestamp.

2021-05-05T15:04:52.000000Z

changing the properties results in an empty column. How to script this?

 

 

aliegner1_0-1622140164904.png

 

jthi
Super User

Re: Convert time from character to continous

@aliegner1  That time format is most likely ISO 8601 time format with milliseconds.I think JMP will recognize it correctly if you were to just remove .000000Z from the end (if you don't need it).

 

One way to get rid of .000000Z would be with formula like:

 

Word(1, :wafer_process_start_time, ".")

 

 

-Jarmo
jthi
Super User

Re: Convert time from character to continous

I would most likely start by fixing the wrong data. If there are only couple of wrong values you could use recode or you could write some formula to do the fixing for you. Below is one option that could work:

Names Default To Here(1);

dt = New Table("Untitled 3",
	Add Rows(5),
	Compress File When Saved(1),
	New Column("datechar",
		Character,
		"None",
		Set Values(
			{"13.05.2021 20:00:00", "13.05.2021 21:00:00", "13.05.2021 22:00:00",
			"13.05.2021 23:00:00", "14.05.2021", "14.05.2021 01:00:00"}
		)
	)
);
wait(1);
Column(dt, "datechar") << Set Each Value(If(Length(:datechar) <= Length("14.05.2021"),
	:datechar || " 00:00:00", :datechar));

 

 

-Jarmo
txnelson
Super User

Re: Convert time from character to continous

@shasheminassab 

I would just pass through the Time(Character) column and add " 00:00:00" if the hours, minutes, seconds do not appear

 

Something like this should work

Names Default To Here( 1 );
dt = Current Data Table();

For Each Row(
	If( Contains( :"Time(Character)"n, ":" ) == 0,
		:"Time(Character)"n = :"Time(Character)"n || " 00:00:00"
	)
);

 

Jim
shasheminassab
Level IV

Re: Convert time from character to continous

Thanks Jim. Very helpful as always.

Sina