[GIS] Convert string into date format problems

arcpydatetime

I have a string column within an attribute table that has a string in the format of:

yyyyMMdd HH:mm:ss (i.e 20150417 13:32:05)

I've tried using the convert time field tool within the python IDE in ArcMap and it's not giving me the full date/time.

import arcpy as arc 

arc.ConvertTimeField_management(in_table="TEST_TIME",
                                input_time_field="Date__Time",
                                input_time_format="yyyyMMdd HH:mm:ss;1033;;",
                                output_time_field="Date_Conv",
                                output_time_type="DATE",
                                output_time_format="yyyyMMdd HH:mm:ss")

I've used both "not used" and the format I want in output_time_format

The resulting output field is always MM/dd/yyyy with no time stamp included.

Best Answer

Try this out:

arc.ConvertTimeField_management("TEST_TIME","Date__Time","yyyyMMdd HH:mm:ss","Date_Conv","DATE")

There are two issues with your code:

  1. Since your input local is not the U.S. (01033), the time gets messed up, so just leave that out
  2. When you chose "DATE" for your output time type, you do not get to chose your "locale", since that is handled by your OS or environmental settings
Related Question