Combining a date and time field

1859
12
12-09-2019 02:04 AM
by Anonymous User
Not applicable

Hi

I have a point shapefile with a date field, called "Date" which is a Date type field.  And I have a time field, called "Time" which is in a String format.

How can I combine these to allow me to enable the use of time for the shapefile?  The only solutions I have found are if these field are both in string format, but I am not sure how to convert the date field to string, using [Date].AsString didn't seem to work

If anyone can help that would be amazing, if possible please be very specific in your response as I am quite a beginner at this sort of stuff.

Thanks

0 Kudos
12 Replies
JoeBorgione
MVP Emeritus

Many times the term shapefile is used generically, if not incorrectly; hence my question as to whether or not you are truly using shapefiles. Windows explorer 'sees' a file geodatase as a folder, but it is truly a database.

What is a geodatabase?—ArcGIS Help | ArcGIS Desktop 

What is a shapefile?—Help | ArcGIS for Desktop 

What is ArcGIS? | ArcGIS for Developers 

That should just about do it....
by Anonymous User
Not applicable

By way of a solution to my original question, here is what I did for anyone else who comes across this:

I originally had a csv file, I used Access to ensure both the Date and Time fields were in string format, and exported as a text file.  I then imported the text file into Arc, and created a point feature class from the file.

  

I then created a new field (called DateTime), this new field type was 'Date'.

Then, using the field calculator I combined the Date and Time fields in this new field using the following (Python parse):

   datetime.datetime.strptime("{} {}".format(!Date!, !Time!), "%d/%m/%Y %H:%M:%S")

JoeBorgione
MVP Emeritus

The csv file represents what type of geometry? I suspect points. Or is it just a table?

At any rate, more suggested reading:

Create points from a table—ArcGIS Pro | Documentation 

Table To Table—Conversion toolbox | ArcGIS Desktop 

You might be able to skip the Access step....

That should just about do it....
0 Kudos