Everything appears to be working fine for me. Could you provide more information about how you're calculating the time difference and how you're storing the time values in the field (i.e. are you storing them as time objects or strings)?
Below is a screenshot of what I'm seeing with the times specified with in your screenshot. I've also included the script I used to test. This script can also create a table with the times shown in your screenshot.
import arcpy
import os
from datetime import datetime
m_fields = [("StartTime", "TEXT"), ("EndTime", "TEXT"), ("ExpectedDiff", "SHORT") , ("TimeDiffFC", "SHORT"), ("TimeDiffUC", "SHORT")]
m_time = [("7:46:35", "7:46:57", 22), ("8:06:10", "8:06:42", 32), ("8:22:54", "8:23:16", 22),
("8:24:51", "8:25:21", 30), ("8:33:22", "8:33:37", 15), ("9:07:56", "9:08:15", 19),
("9:10:47", "9:15:01", 254), ("9:21:39", "9:25:33", 234), ("9:29:51", "9:30:22", 31)]
def createdata(folder):
outPath = os.path.join(folder, "data")
if os.path.exists(outPath):
arcpy.management.Delete(outPath)
os.makedirs(outPath)
gdb = arcpy.management.CreateFileGDB(outPath, "data.gdb")
tab = arcpy.management.CreateTable(gdb, "TimeTable")
for fname, ftype in m_fields:
arcpy.management.AddField(tab, fname, ftype, field_length=8 if ftype == "TEXT" else "#")
with arcpy.da.InsertCursor(tab, [f[0] for f in m_fields][:3]) as cursor:
for time in m_time:
cursor.insertRow(time)
return tab
def calcTime(table):
arcpy.management.CalculateField(table, "TimeDiffFC", "(datetime.datetime.strptime(!{0}!, \"{2}\") - datetime.datetime.strptime( !{1}!, \"{2}\")).seconds".format("EndTime", "StartTime", "%H:%M:%S"), "PYTHON")
with arcpy.da.UpdateCursor(table, [f[0] for f in m_fields]) as cursor:
for row in cursor:
row[4] = (datetime.strptime(row[1], "%H:%M:%S") - datetime.strptime(row[0], "%H:%M:%S")).seconds
cursor.updateRow(row)
if __name__ == '__main__':
if '__file__' in dir():
srcPath = os.path.dirname(__file__)
else:
from sys import argv
srcPath = os.path.dirname(argv[0])
table = createdata(srcPath)
calcTime(table)