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.
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.
Show Codeblock: checked
Pre-Logic Script Code:
def FindDate(date): if date is None: return None else: return date.split(" ").pop(0)
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.
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:
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