Skip to Content
author's profile photo Former Member
Former Member

Custom Function to determine seconds elapsed

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, ' hh24:mi:ss'))2460*60);

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

$Test = to_date(sysdate(), ' 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?

Add a comment
10|10000 characters needed characters exceeded

Assigned Tags

Related questions

1 Answer

  • author's profile photo Former Member
    Former Member
    Posted on Jan 18, 2012 at 04:52 PM

    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'));

    Add a comment
    10|10000 characters needed characters exceeded

Before answering

You should only submit an answer when you are proposing a solution to the poster's problem. If you want the poster to clarify the question or provide more information, please leave a comment instead, requesting additional details. When answering, please include specifics, such as step-by-step instructions, context for the solution, and links to useful resources. Also, please make sure that you answer complies with our Rules of Engagement.
You must be Logged in to submit an answer.

Up to 10 attachments (including images) can be used with a maximum of 1.0 MB each and 10.5 MB total.