2

I have a time field in my shapefile that is formatted as HH:mm:ss.s It is a text field, and I want to convert it to a date so I can calculate time elapsed across rows (if there's a better way to do this let me know). Basically, each row is a point on a route, and I want to use the time field to calculate the amount of time elapsed between the first and last points on the route.

I tried using the convert time field tool, setting the input format as HH:mm:ss.s, and the output type as DATE. The output field however only shows values of 01/01/2001 for some rows and for other rows.

time is the input field and time_c is the output field

I'm not sure what's going wrong here, here is what shows up in the geoprocessing results window:

I tried adding the date data to the field as well to make the format yyyy-MM-dd HH:mm:ss.s, but it still didn't work:

enter image description here

  • Have you tried altering the precision in the time field to only allow "ss.s" instead of what it has there: "ss.sss"? – Ben Ference Jul 20 '15 at 20:59
  • according to the arcgis resource center site, "Although the format only shows one decimal place, any number of decimal places can be used." I did try that though and it still didn't work. – nkt95 Jul 20 '15 at 21:07
  • Since your input data only contains hour/minute/second information, maybe converting it to a day just can't be done. And since it doesn't have that information it's giving you NULL/Jan 1st/2001 results? According to the "Supported field formats" (resources.arcgis.com/en/help/main/10.1/index.html#//…) you need to have a YYYY for it to work properly and a MM is suggested. – Ben Ference Jul 20 '15 at 21:28
  • Shapefiles don't support time fields with greater than day precision. Even file geodatabase doesn't support subsecond timestamps. – Vince Jul 20 '15 at 21:35
  • So I tried adding date data to the field, so now it's in the format yyyy-MM-dd HH:mm:ss.s, and the output was the same, just the date this time was 11/06/2015 (the correct date) instead of 01/01/2001. – nkt95 Jul 20 '15 at 21:41
4

Shapefiles utilize dBase-III+ date values ('D' type), which are restricted to day resolution. If you need second resolution, you'll need to use a personal, file, or enterprise geodatabase.

It would probably be best to round the fractional seconds to the nearest second, since Desktop's time structure (struct tm) doesn't support subsecond precision at this time.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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