Convert DB2 function SecondsSinceFromTimestamp to SQL


I am writing a testing query for an ETL DataStage job, developer used SecondsSinceFromTimestamp to get the Returns the number of seconds between two timestamps. However, I cannot find the equivalent to SQL.

If NullToValue(src_data_link.Waste_Before_Timestamp,PS_COMMON.MIN_TS) = PS_COMMON.MIN_TS
Then -1
Else SecondsSinceFromTimestamp(NullToValue (src_data_link.After_TimeStamp,PS_COMMON.MIN_TS), NullToValue (src_data_link.Waste_Before_Timestamp,PS_COMMON.MIN_TS)) /60

Please help me.

Thank you!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Kent OlsenDBACommented:
Hi Huyenb,

Use the function timestampdiff() to return the interval between two timestamps.

  timestampdiff (unit, timestamp1, timestamp2);

For seconds, pass 2 for the unit.
Both of the timestamp values must be cast as strings.

  timestampdiff (2, cast (ts1 as varchar (20)), cast (ts2 as varchar (20))

Good Luck!

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
huyenbAuthor Commented:
Hi Mr. Kdo,

Thank you so much for your solution
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.