cancel
Showing results for 
Search instead for 
Did you mean: 

Custom Function to determine seconds elapsed

Former Member
0 Kudos

Hello All! I have a simple custom function created that is supposed to calculate the seconds elapsed between two datetime values. Here is the code and I'm wondering why it is returning 0 for the seconds elapsed. If I change the code to sysdate()-1 then it shows that 86400 seconds have elapsed.

Note, the $JobStartDate is a Datetime data type.

return((sysdate() - to_Date($JobStartDate, 'yyyy.mm.dd hh24:mi:ss'))2460*60);

The variable that gets sent to the functions $JobStartDate parameter is this

$Test = to_date(sysdate(), 'yyyy.mm.dd hh24:mi:ss');

which when sent through the print() function displays as '2012.01.18 7:52:00'

I then sleep() for 5 seconds and call the function

$SecondsElapsed = ElapsedSeconds($Test)

Print() the $SecondsElapsed variable and it displays 0

What am I missing here?

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

Annnnd I figure it out myself. I should have been using date_diff() inside the function, comparing Seconds. Final custom function looks like this:

return(date_diff($JobStartDate, sysdate(), 'S'));