ArcGIS for Desktop

  • Documentation
  • Pricing
  • Support

  • My Profile
  • Help
  • Sign Out
ArcGIS for Desktop

ArcGIS Online

The mapping platform for your organization

ArcGIS for Desktop

A complete professional GIS

ArcGIS for Server

GIS in your enterprise

ArcGIS for Developers

Tools to build location-aware apps

ArcGIS Solutions

Free template maps and apps for your industry

ArcGIS Marketplace

Get apps and data for your organization

  • Documentation
  • Pricing
  • Support
Esri
  • Sign In
user
  • My Profile
  • Sign Out

Help

  • Home
  • Get Started
  • Map
  • Analyze
  • Manage Data
  • Tools
  • More...

Convert Time Field

  • Summary
  • Illustration
  • Usage
  • Syntax
  • Code sample
  • Environments
  • Licensing information

Summary

Converts time values stored in a string or numeric field to a date field. The tool can also be used to convert time values stored in string, numeric, or date fields into custom formats such as day of the week, month of the year, and so on.

Illustration

Converting string or numeric field containing time values into a date field
In the illustration, the time values stored as strings in the Input_Time field that were collected in the format MMMM d, yyyy HH:mm:ss have been converted into time values stored as date values in the Output_Time field.

Usage

  • If the input time field selected is a string or text field, the input time format can be selected from a list of supported time field formats. or you can define a custom time field format to interpret custom date and/or time values in the string field. For more information about custom formats for string fields, see converting string time values into date format.

  • If the input time field selected is numeric (short, long, float, or double), the input time format can be selected from a list of supported standard time field formats. Custom time formats are not supported with numeric fields.

Syntax

ConvertTimeField_management (in_table, input_time_field, {input_time_format}, output_time_field, {output_time_type}, {output_time_format})
ParameterExplanationData Type
in_table

The layer or table that contains the field containing the time values that need to be converted.

Table View
input_time_field

The field containing the time values. May be of type short, long, float, double, text, or date.

Field
input_time_format
(Optional)

The format in which the time values were stored in the input time field. Either a standard time format can be selected from the drop-down list, or a custom format can be entered. If the data type of the time field is numeric (Short, Long, Float, or Double), a list of standard numeric time formats is provided in the drop-down list. If the data type of the time field is string, a list of standard string time formats is provided in the drop-down list. For string fields, you can also choose to specify a custom time format. For example, the time values may have been stored in a string field in one of the standard formats such as yyyy/MM/dd HH:mm:ss or in a custom format such as dd/MM/yyyy HH:mm:ss. For the custom format, you can also specify the a.m., p.m. designator.

If the data type of the time field is date, then no time format is required.

Learn more about custom dates and time formats

String
output_time_field

The name of output field in which the converted time values will be stored.

String
output_time_type
(Optional)

The data type of the output time field.

  • DATE —Date and/or time.
  • TEXT —Any string of characters
  • LONG —Whole numbers between -2,147,483,648 and 2,147,483,647.
  • SHORT —Whole numbers between -32,768 and 32,767.
  • DOUBLE —Fractional numbers between -2.2E308 and 1.8E308.
  • FLOAT —Fractional numbers between -3.4E38 and 1.2E38.
String
output_time_format
(Optional)

The format in which the output time values will be saved. The list of output time formats depends on the output data type specified for the output time field.

String

Code sample

ConvertTimeField example 1 (Python window)

The following Python window script demonstrates how to use the ConvertTimeField tool in immediate mode.

import arcpy
arcpy.ConvertTimeField_management("C:/Data/TemporalData.gdb/Input_Table","Input_Time","1033;MMMM dd, yyyy HH:mm:ss;AM;PM","Output_Time")
ConvertTimeField example 2 (stand-alone script)

The following stand-alone script demonstrates how to use the ConvertTimeField tool.

# Name: ConvertTimeField_Ex02.py
# Description: Convert a time field to date field
# Requirements: None

# Import system modules
import arcpy

# Set local variables
inTable = "C:\Data\TemporalData.gdb\Input_Table"
inputTimeField = "Input_Time"
inputTimeFormat = "1033;MMMM dd, yyyy HH:mm:ss;AM;PM"
outputDateField = "Output_Time"

# Execute CalculateEndDate
arcpy.ConvertTimeField_management(inTable, inputTimeField, inputTimeFormat, outputDateField)

Environments

This tool does not use any geoprocessing environments

Licensing information

  • ArcGIS for Desktop Basic: Yes
  • ArcGIS for Desktop Standard: Yes
  • ArcGIS for Desktop Advanced: Yes

Related topics

  • An overview of the Fields toolset

ArcGIS for Desktop

  • Home
  • Documentation
  • Pricing
  • Support

ArcGIS Platform

  • ArcGIS Online
  • ArcGIS for Desktop
  • ArcGIS for Server
  • ArcGIS for Developers
  • ArcGIS Solutions
  • ArcGIS Marketplace

About Esri

  • About Us
  • Careers
  • Insiders Blog
  • User Conference
  • Developer Summit
Esri
Tell us what you think.
© Copyright 2016 Environmental Systems Research Institute, Inc. | Privacy | Legal