cancel
Showing results for 
Search instead for 
Did you mean: 

Duration field is giving incorrect result in substrating two date and time field

neha_mahanty
Active Participant
0 Kudos

Hi All,

I am working on a requirement where I need to find the difference between two date and time field.

Diff

    StartDateandTime

    ConfirmationDateandTime

I tried to take the difference directly and store in Decimal field but it was giving incorrect and wierd results .

Hence I created a field of type duration to store the difference of these two date field but every time the duration is giving only one result. 23:59:59

I even displayed the StartDateandTime directly in duration field to check if the same date is displayed there but it gave me the same 23:59:59

Please guide . Also please share if anyone has worked on similar requirement to find the difference between two date and time field

Thanks

Neha

Accepted Solutions (0)

Answers (1)

Answers (1)

jason_latko
Advisor
Advisor
0 Kudos

Neha,

Agentry Date/Time variables keep the number of seconds past the Agentry epoch (Jan 1, 2001?).  You can take the DIFF between two DateTime properties to get the difference in seconds like you suggested.  Not sure why you are having trouble with this.  Make sure you always subtract the smaller from the larger.

I created a test screen with two DateTime fileds: Date1 and Date2.  The third field is an Integer called Diff that has an update rule to calculate the difference between the two.  It checks to see which date is larger before doing the DIFF.

Above image displays 86,400 seconds which is the number of seconds in 24 hours.  This is the difference between Date1 subtracting Date2.

Above image displays 172,800 seconds which is the number of seconds in 48 hours.  This is the difference between Date2 subtracting Date1.

Above image shows the update rule that does the math.

Jason Latko - Senior Product Developer at SAP