Select to view content in your preferred language

Time format with milliseconds

3443
1
Jump to solution
05-19-2023 05:57 AM
Labels (2)
xyz_AL
by
New Contributor III

Hi all,

I need to convert date & time text field in a date field.

The input is like that: "11-05-2023 08:26:01.953".

Using the "Convert Time Field" tool with the input time format option in milliseconds (dd-MM-yyyy hh:mm:ss.s) the output in the new converted field is 11/05/2023 08:26:01 with no milliseconds.

I've read that this was a bug, but some years ago....

I've also tryed to create a new date field to store just time, settimg the format like this:

xyz_AL_0-1684501437782.png

As you can see the milliseconds seem to be correctly set....

I use ArcGIS Pro 3.1.0

Any news or idea on how to do that? Thanks

0 Kudos
1 Solution

Accepted Solutions
JohannesLindner
MVP Frequent Contributor

Convert Time Field indeed seems to ignore milliseconds.

Instead, you can use Calculate Field with this Python expression:

datetime.datetime.strptime(!TextField1!, "%d-%m-%Y %H:%M:%S.%f")

 

(Replace "TextField1" with the name of your text field, take care that the name is surrounded by exclamation marks)

 

Here's a quick test of the Converted vs. the Calculated dates (after I set the Date format for both fields):

JohannesLindner_0-1684512492020.png

 


Have a great day!
Johannes

View solution in original post

1 Reply
JohannesLindner
MVP Frequent Contributor

Convert Time Field indeed seems to ignore milliseconds.

Instead, you can use Calculate Field with this Python expression:

datetime.datetime.strptime(!TextField1!, "%d-%m-%Y %H:%M:%S.%f")

 

(Replace "TextField1" with the name of your text field, take care that the name is surrounded by exclamation marks)

 

Here's a quick test of the Converted vs. the Calculated dates (after I set the Date format for both fields):

JohannesLindner_0-1684512492020.png

 


Have a great day!
Johannes