We have a very strange problem in date time storing in database. GETUTCDATE
function is used in a stored procedure to update a job start time stamp and end time stamp. The stored procedure is called from server side .net code once for start and again to update end time stamp. The problem is 'end time stamp' is earlier than the start time stamp. Similar issue is mentioned in this SO question but it did not help me solve our issue.
Stored procedure code:
@Id int,
@Status int
if (@Status = 3) -- Processing
Begin
Update QUEUE
Set STATUS = @Status,
PROCESSING_START_TIMESTAMP = getutcdate()
Where ID = @Id
End
Else if (@Status = 4) -- Completed
Begin
Update QUEUE
Set STATUS = @Status,
PROCESSING_END_TIMESTAMP = getutcdate()
Where ID = @Id
End
Else -- Failed
Begin
Update QUEUE
Set STATUS = @Status
Where ID = @Id
End
From vb.net we call this stored procedure to set start time stamp, process some job and set end time stamp.
' Set Status to Processing
ldbQueueMaster.SaveStatus(liQueueEntryId, 3)
' Call the Processor
Dim lbCompleted = lQueueProcessor.Processor(lQueueMaster, lsRootPath)
' Set the Status based on Return from the Processor
If (lbCompleted) Then
ldbQueueMaster.SaveStatus(liQueueEntryId,4) 'Completed
Else
ldbQueueMaster.SaveStatus(liQueueEntryId, 5) 'Failed
End If
Result from database:
ID PROCESSING_START_TIMESTAMP PROCESSING_END_TIMESTAMP
-------------- -------------------------------- ----------------------------
9533789 2016-08-03 18:34:22.190 2016-08-03 18:34:22.187
Any help would be appreciated.