cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Learn how to build custom Python data connectors and further customize JMP’s Data Connector Framework with the Python Data Connector Demo, available now in the JMP Marketplace!
  • See how to use Accelerated Life Testing (ALT) to evaluate reliability. Register for June 5 webinar, 2pm US Eastern Time.

Discussions

Solve problems, and share tips and tricks with other JMP users.
Choose Language Hide Translation Bar
mvanderaa1
Level IV

convert number to datetime with milliseconds

Hi, I have a column with values of the following format: '20230818103947300000'

I was hoping to be able to convert it using the custom format (i.e. <YYYY><MM><dd> etc), but I do not see the option for milliseconds. Of course I can make a long formula to extract each individual element and then adding them together, but I really want to avoid that.

 

For reference, in python I am able to do this in one line to get my datetime object dt:

from datetime import datetime
d='20230818103947300000'
dt=datetime.strptime(d,'%Y%m%d%H%M%S%f')

1 REPLY 1
jthi
Super User

Re: convert number to datetime with milliseconds

Seems like you have to have "." as separator within seconds

Names Default To Here(1);

str = "20230818103947300000";
Insert Into(str, ".", Length("YYYYMMDDHHMMSS") +1);
date_formatted = Informat(str, "Format Pattern", "<YYYY><MM><DD><hh24><mm><ss>");
date_with_ms = Format(date_formatted, "yyyy-mm-ddThh:mm:ss", 25,3); // "2023-08-18T10:39:47.300"
-Jarmo

Recommended Articles