2

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.

  • What is your intended output? To me it looks like its the same as your intended input. And what is the 1033 you have? I also see it in ESRI's documentation, but there doesn't seem to be an explanation. Also this post might help: gis.stackexchange.com/questions/13318/… – Dave-Evans Jun 8 '16 at 14:31
  • I would like my new filed to be exactly the same but as a 'date' format rather than a string. I will try the link, thanks for that. – Yolo_chicken Jun 8 '16 at 14:39
  • As I explore further, does ArcMap store date and time in the same column and just not display the time? – Yolo_chicken Jun 8 '16 at 14:46
  • @Dave-Evans - 01033 is the "Locale" (i.e. United States) – alexGIS Jun 8 '16 at 18:05
  • what is the time you are trying to store? ArcGIS will display date or date and time depending on what time information there is available – Midavalo Jun 8 '16 at 18:11
3

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
  • Similarly, I have a string field 'HH:mm:ss' that I would like as a 'date' format and when I use convert it adds a date to the output, when I would only like time to populate the field. Thoughts? – Yolo_chicken Jun 27 '16 at 16:13
0

I'm a couple of years late to the party, but...

You didn't state how your data is stored, but from your results, I'm guessing that you're using a shapefile because I've gotten similar results in the past using shapefiles. I learned the hard way that the shapefile date storage format can only contain dates. It does not allow date and time together.

As a solution, convert your shapefile to a FGDB feature class, as its date format can store date, time or dates and time together.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.