3

I'm trying to copy the dates from a field called InspectionDate (date data type) to new field called CompletedDate (date data type) but I don't want the time stamp to be copied over. How can I copy just the date in a mm,dd,yyyy format using field calculator. For example copying 1/1/2016 12:00:00 AM to new field as 1/1/2016.

  • 2
    Just a guess but perhaps you can try removing the last 12 characters (including spaces) which may leave you with your date: left("InspectionDate", len("InspectionDate") - 12) – Joseph Feb 29 '16 at 15:59
4

You can't remove the Hours/Minutes/Seconds while using the Date field type. You will have to convert to an alternative field type.

From ESRI on Working with Date Fields:

Enter dates in MM/DD/YYYY hh:mm:ss format

Regardless of how dates are displayed in the table, you can only enter dates in MM/DD/YYYY hh:mm:ss format, enclosed in single quotation marks. For example, to set a date field to 5:00PM on May 27, 2014, you would type '05/27/2014 05:00:00PM', '05/27/2014 5:00PM', or '05/27/2014 17:00:00' (24-hour clock). Storing time alone is not supported—time must always be a component of a date.

To correct I would suggest creating a string(text) field type as it will allow the format you are seeking of MM/DD/YYYY.

  • I did need to make a text field as you suggested and I used the left function mentioned by Joseph. Thanks. – user19300 Feb 29 '16 at 16:35
4

Storing time alone is not supported, but dates can be stored without time. I just happened to be doing this - I have a date field with date/time stamps and I only want date stamps. I used these field calculator settings - replace DATEFIELD with your field name.

Parser: Python

Show Codeblock: checked

Pre-Logic Script Code:

def FindDate(date):
    if date is None:
        return None
    else:
        return date.split(" ").pop(0)

DATEFIELD =

FindDate(!DATEFIELD!)

ArcGIS field calculator screenshot

0

Your problem might be simpler than you think. Sometimes you may need to export your data to a different format before exploring much more complicated steps like field calculators:

Displaying dates

A coverage or shapefile stores dates in a date field with this format: yyyy-mm-dd. A geodatabase formats the date as datetime yyyy-mm-dd hh:mm:ss AM or PM. Settings on your Windows system determine how the dates are displayed in ArcMap—M/d/yy, MM/dd/yy, yy/MM/dd, and so on. ArcMap uses the system short date format (numerical) for displaying dates

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.