So I'm calculating total drive times in Network Analyst. I have an end time field that I'm trying to strip the minutes and seconds from for a new field. It's a date field formatted like so: 9/16/2019 8:01:06 AM. I enter Minute(EndTime) + ":" + Second(EndTime) in the field calculator. The issue is, I'm getting resulting times like 1:6 which should read 1:06, or one minute, six seconds. What gives??
Solved! Go to Solution.
I used this Text(EndTime, 'mm:ss')
Try the following: Text(EndTime, 'm:ss')
Hi Levi Cecil ,
In addition to the correct answer provided by Lance Cole , it is important to understand that the Second function returns a number, not a text:
Second( dateValue ) -> returns:
Number
See: Date Functions | ArcGIS for Developers
You want to get the result in a certain format and that is obtained by using the Text function as Lance described. In this case you don't have to use the Second and Minute functions, but by providing the desired format "m:ss" or "mm:ss" (what ever suits your need most) you can use a single function. To see more formatting options, please see: Data Functions | ArcGIS for Developers
Thanks Xander. This works, but only for times over one minute (see screenshot).
I used this Text(EndTime, 'mm:ss')
Hi Levi Cecil ,
I tested this in the playground here: ArcGIS Arcade | ArcGIS for Developers and it works there if I define a date as the one you have:
When I do the same in ArcGIS Pro:
It also seems to work:
Not sure what is going wrong in your case...
I added the extra 'm' to your original solution Text(EndTime, 'mm:ss'). A single 'm', Text(EndTime, 'm:ss') results in an empty string if the time is less than a minute.