Does anyone have any suggestions on how I can convert this field into a date/time. I converted it from kml to shp file and all the information was in one field. I tried using the Convert Time Field tool but it failed.
Solved! Go to Solution.
I added in the two additional lines of the expressions but it does not pull the timestamp.
Hi @DonovanC ,
As far as I understand, the way a date time is shown in ArcGIS Pro depends on the settings of your system: https://pro.arcgis.com/en/pro-app/latest/help/data/tables/date-fields.htm
You can validate this using the pop-up and define an expression to return the date and time using the format that you want. An example:
return Text($feature["Name of your date field"], "Y-MM-DD HH:mm:ss");
Hi @DonovanC ,
Earlier on you also mentioned using Python for the field calculation. This should return the same result.
def ParseDateTime(tst):
import datetime
dt_format1 = "%d-%m-%Y %H:%M:%S"
dt_format2 = "%m/%d/%y %I:%M:%S %p"
if "-" in tst:
txt = tst[1:20]
dt = datetime.datetime.strptime(txt, dt_format1)
return dt
else:
txt = tst[1:21]
dt = datetime.datetime.strptime(txt, dt_format2)
return dt
ParseDateTime(!kml_des!)
Thanks for all your help!!