Convert 5 digit date serial number to MM/DD/YYYY

33536
11
Jump to solution
04-01-2016 12:28 PM
PhilLampe1
New Contributor II

Hello,

I have a string field (named StartDate) in an attribute table that contains numerous 5 digit (post 1900, Excel style) values (such as 40,240) that I need to convert into into a readable date format (which in this case would be MM/DD/YYYY).

I have created an empty field named StartDateDT to house the converted serial dates.  The field is in DATE format.

What is the code in VB (preferred) or python to do this?

I am using ArcMap 10.22, standard (aka ArcEditor) license, BTW.

Many THANKS in advance!

Phil in Houston

11 Replies
DanPatterson_Retired
MVP Emeritus

No, Managing Data is fine since it is really just about a data format conversion and not specific to Python or Geoprocessing.

0 Kudos
deleted-user-8TJ6jZDO1Rfr
New Contributor III

Dealt with this issue today. Your code worked after we told it to view the string field as an integer.

This is the code we used in the Field Calculator:

datetime.datetime(1899,12,30) + datetime.timedelta(days = int( !START_DATE!))

Related Links:

https://community.esri.com/ideas/16476-excel-to-table-date-conversion

https://community.esri.com/thread/231594-date-field-in-excel-to-table-tool