ArcGIS Pro DateTime – Merge Date and Time Columns to Combined Date Column

arcgis-prodatetimespace-time-cube

So my dataset has two columns, Date (type Date) and Time (type Text) as shown in the screenshot below. Now, I would like to merge the two together and then create a new date column using the "Add Date Attributes" tool. This new column will then be provided to the "Create Space Time Cube From Defined Locations (two points)" tool showing the change in values with respect to time.

How can I merge these two columns and create a proper date column in ArcGIS Pro that can be used in "Create Space Time Cube From Defined Locations (two points)"?

enter image description here

Best Answer

Try this code with the Calculate Field function where the output field is of type date: enter image description here

Here is the code:

var rec_time = $feature.survey_time;
var str_len = count(rec_time);

IIF(str_len ==7,rec_time = concatenate('0',rec_time),0);

var isAM = IIF(right(rec_time,2)=='AM',true,false);
var hours = ceil(left(rec_time,2),0);
var minutes = ceil(mid(rec_time,3,2),0);

IIF ((isAM==false) && (hours !=12),hours=hours+12, 0);
IIF ((isAM) && (hours ==12),hours=0, 0);

var hours_in_minutes = hours * 60;

var total_minutes = hours_in_minutes+minutes;
dateadd($feature.survey_date,total_minutes,'minutes');
Related Question