Convert HH.MM.SS to Seconds



IBM's flagship relational database management system

Convert HH.MM.SS to Seconds

Postby coldplay1991 » Sat Dec 10, 2011 2:21 am

Does anyone know how to convert HH.MM.SS to seconds.
I want to covert HH.MM.SS to Seconds using DB2 on z/OS.
Then I want to ensure that those two values are within plus or minus of 30 seconds.
How will I do that?
coldplay1991
 
Posts: 59
Joined: Tue Nov 15, 2011 5:47 am
Has thanked: 0 time
Been thanked: 0 time

Re: Convert HH.MM.SS to Seconds

Postby Akatsukami » Sat Dec 10, 2011 3:12 am

coldplay1991 wrote:Does anyone know how to convert HH.MM.SS to seconds.
I want to covert HH.MM.SS to Seconds using DB2 on z/OS.
Then I want to ensure that those two values are within plus or minus of 30 seconds.
How will I do that?

Probably by using MIDNIGHT_SECONDS.
"You have sat too long for any good you have been doing lately ... Depart, I say; and let us have done with you. In the name of God, go!" -- what I say to a junior programmer at least once a day
User avatar
Akatsukami
Global moderator
 
Posts: 1058
Joined: Sat Oct 16, 2010 2:31 am
Location: Bloomington, IL
Has thanked: 6 times
Been thanked: 51 times

Re: Convert HH.MM.SS to Seconds

Postby AnandB » Tue Dec 27, 2011 10:29 am

TIMESTAMPDIFF could be one alternative

SELECT
TIMESTAMPDIFF(02, CHAR(TIMESTAMP('1997-02-01-01.03.30')
- TIMESTAMP('1997-02-01-01.02.00'))) will give us a integer value of 90.
Anand Biradar
AnandB
 
Posts: 6
Joined: Mon Dec 26, 2011 1:20 pm
Has thanked: 1 time
Been thanked: 0 time

Re: Convert HH.MM.SS to Seconds

Postby Nik22Dec » Tue Dec 27, 2011 2:37 pm

Yes..MIDNIGHT_SECONDS can definitely do that. A sample SQL would look like -

SELECT MIDNIGHT_SECONDS('12.12.12') FROM DB2.DUMMY;

Thanks & Regards,
Nik
Thanks,
Nik
User avatar
Nik22Dec
 
Posts: 68
Joined: Mon Dec 26, 2011 6:38 pm
Has thanked: 2 times
Been thanked: 0 time


Return to DB2

 


  • Related topics
    Replies
    Views
    Last post