ArcMap 10.4 – Using python function in field calculator to update date values from another column

In ArcMap 10.4 you can use a python function to update the date type value of one column from another column using field calculator. Below a code snippet on how to achieve this provided that the date value is not just time.

Step 1 – Select the layer that you want to make update to. Right click on the layer and select open attribute table from the pop up menu.








Step 2 – Highlight the rows of data you want to make changes to and then right click on the header of the column. Select Field Calculator from the pop up menu.




Step 3 – In the Field Calculator dialogue box select¬† “Show Codeblock”. Add the python function in the section where it says ‘Pre-Logic Script Code’:

from datetime import datetime

def validate(date_text):
if date_text != datetime.strptime(date_text, "%m/%d/%Y").strftime('%H:%M:%S'):
return date_text
except ValueError:
return None

In the section below add a call to the function:


Arcmap attribute table
Open your layers attribute table
Arcmap Field Calculator Python Function
Add your custom python function in Field Calculator
ArcMap Field Calculator Python Function
Add your custom python function here

Leave a Reply

No apps configured. Please contact your administrator.

How to code your own sFTP File Uploader Windows application using C# and SSH

Creating your own SFTP application is now easier than ever. Using C# allows you to easily create a windows application to securely transfer your files. SFTP stands for SSH File Transfer Protocol. SSH is an encrypted and secure communication protocol

Loading Data from Multiple Tables into Data Grid using Entity Framework

Total Page Visits: 1719 – Today Page Visits: 3

XLS to DBF File Conversion using ExcelDataReader

ExcelDataReader is a lightweight and fast library written in C# for reading Microsoft Excel files (2.0-2007). Below is code that will read an xls file, skip the headers and write data in DBF format.

Total Page Visits: 1719 - Today Page Visits: 3