cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
The Discovery Summit 2025 Call for Content is open! Submit an abstract today to present at our premier analytics conference.
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