Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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 VBS and Python date functions, but nothing seems to work.

Would I make my new field type text?

share|improve this question
It would help to know how the serial date was created? Is this from excel? – Jamie Jan 2 '13 at 16:35
@Gord, How are you getting 06:33 from 41256.260799. I? Do you have another example you could post? – artwork21 Jan 2 '13 at 17:11
@artwork21. My mistake, I meant to type hour and minute above... from 41256.260799 I'm getting 06:15:33. I want to create a field that will display just 06:15 as a label. – Gord Jan 2 '13 at 18:07
@artwork21 is based on the values that excel and other spreadsheets use. By default, January 1, 1900 is serial number 1. But becasue the OP only wants the hours and minutes they only need the fractional part. – mhoran_psprep Jan 2 '13 at 18:11

This page is a good guide if you're asking what I think you're asking.

From here, you can get the string you want fairly easily in Python using datetime:

import datetime
new_dt = datetime.datetime(1899, 12, 30) + datetime.timedelta(days=41256.260799)
formatted_string = new_dt.time().strftime("%H:%S")

That should be pretty easy to refactor into a function for the field calculator.

share|improve this answer

If you just need it for a label, use it in the label expression.

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

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