on 01-18-2012 2:56 PM
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?
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'));
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
81 | |
10 | |
10 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.