Parsing serial date field

209
1
01-02-2013 05:17 AM
GordDeVillers
New Contributor
Hello,

I have imported a shapefile that contains a serial date number that looks like this: 41256.260799 . I would like to create a new field that shows only the hour and second like this 06:33 . I've tried the available vb and python date functions, but nothing seems to work. Would I make my new field type text? Any help appreciated.

Gord
0 Kudos
1 Reply
JakeSkinner
Esri Esteemed Contributor
Hi Gord,

You could use the following python function within the field calculator:

def date(field):
  seconds = (field - 25569) * 86400.0
  time = str(datetime.timedelta(seconds=seconds))
  return time.split(",")[1].split(".")[0]


Here is a screen shot.

[ATTACH=CONFIG]20365[/ATTACH]
0 Kudos