Share your ideas for the JMP Scripting Unsession at Discovery Summit by September 17th. We hope to see you there!
Choose Language Hide Translation Bar
Highlighted
WHG
WHG
Level I

Convert character timestamp to typical numeric format

I would like to convert a character timestamp format like this one:

06/28/19 11:26:29:252

to a typical numeric format

06/28/19 11:26:29

Any help much appreciated.

7 REPLIES 7
Highlighted
johnmoore
Level IV

Re: Convert character timestamp to typical numeric format

Give this a try

characterStamp = "06/28/19 11:26:29:252";

lastPart = ":"||word(4,characterStamp,":");
substituteinto(characterStamp,lastPart,"");

numberStamp = informat(characterStamp,"m/d/y h:m:s")
Highlighted
WHG
WHG
Level I

Re: Convert character timestamp to typical numeric format

How do I apply the script to convert the old format to the new format, let's say for all values from column 1 to column 2?

Highlighted
txnelson
Super User

Re: Convert character timestamp to typical numeric format

The easiest way to do this is to right click on the column header for Column 2 and select "Formula".

Then place the following into the formula window

characterStamp = :column 1;
lastPart = ":"||word(4,characterStamp,":");
substituteinto(characterStamp,lastPart,"");

informat(characterStamp,"m/d/y h:m:s")
Jim
Highlighted
WHG
WHG
Level I

Re: Convert character timestamp to typical numeric format

This leads to this:

Capture.PNG

Any help much appreciated.

Highlighted
johnmoore
Level IV

Re: Convert character timestamp to typical numeric format

Almost there. Just change the format of the column to the date/time format you want.
Highlighted
WHG
WHG
Level I

Re: Convert character timestamp to typical numeric format

Fantastic. Thank you!

Highlighted
Jeff_Perkinson
Community Manager Community Manager

Re: Convert character timestamp to typical numeric format

Article Labels

    There are no labels assigned to this post.