Tuesday 11 October 2016

arcgis desktop - Converting 12-hour time to 24-hour time using Field Calculator


Does anyone know how to convert string time formats in ArcMap v10.2 from 12-hour to 24-hour using a simple query in the Field Calculator? i.e. NO Python, NO editing in Excel, NO changing my Windows PC settings, etc...


This is a successful calculation I used (which I found on a discontinued forum) to convert my dates from MM/DD/YYYY to YYYY/MM/DD:


year([DateFld]) & "/" & Month([DateFld]) & "/" & Day([DateFld])


Perhaps there is some sort of modification that I could make to the above calculation that would change my times to 24-hour? I've searched for an answer everywhere and played around with it without any luck, but I would like for the times to be in h:mm:ss format.


Forgot to mention that this is a regular shapefile, not part of a GDB.




Answer



There is actually an ArcGIS tool specifically for this task: Convert Time Field. You don't even need to use the Field Calculator. Just specify the format of the source date/time field and your desired output format and the tool will create a new field and populate it with the converted values. It can be used for converting dates, times, or a combination of both.


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...