Using DateDiff() Function in ArcGIS Field Calculator

4067
1
04-18-2014 12:39 PM
Highlighted
New Contributor
I am trying to calculate the time difference between two fields using the DateDiff() function in minutes. I have successfully calculated the times that fall within the same day but I am having trouble with the times that are occurring in day transition (after 11:59 PM). For example: My date fields are as such,

MM\dd\yyyy hh:mm:ss tt

So between these two times

01\17\2007 11:57:08 PM and 01\18\2007 12:15:01 AM

The field calculator would apply a huge negative number. I am thinking a conditional statement is needed for basic arithmetic but am at a loss.

Please be as detailed as possible. I am not a developer.
Tags (2)
Reply
0 Kudos
1 Reply
Highlighted
New Contributor
The formula I am using is: DateDiff("s", Field1, Fields). The problem with different days is mentioned above. The DateDiff() function doesn't "consider the date when it looks at the hh:mm:ss tt section of the field's row values. In using my example above, when DateDiff() calculates the number of seconds between 11:57:08 PM and 12:15:01 AM the calculation looks like this: 12:15:01 AM subtract 11:57:08 PM. If you looked at it in military time 00:15:01 - 23:57:08 or 901 seconds subtract 86222 seconds or 901-86222 = -85321. The answer is -85321. I know how to do this in Excel, not ArcGIS.
Reply
0 Kudos