View previous topic :: View next topic
|
Author |
Message |
Sivagurunathan Jagadeesan
New User
Joined: 06 Mar 2007 Posts: 32 Location: India
|
|
|
|
Hi,
I am working in Enterprise COBOL and DB2 in Mainframes.
How do i convert a Time in (HH:MM:SS AM/PM) format to 24 hours format(HH:MM:SS). I tried using the ALTTIME function but the Schema DSN8 which this functions belongs to, is not working.
Thanks in Advance,
Siva |
|
Back to top |
|
|
wanderer
Active User
Joined: 05 Feb 2007 Posts: 199 Location: Sri Lanka
|
|
|
|
When you say 'not working', what kind of error message you get? |
|
Back to top |
|
|
Sivagurunathan Jagadeesan
New User
Joined: 06 Mar 2007 Posts: 32 Location: India
|
|
|
|
Hi,
The fuction ALTTIME is not recognized as an valid one. Message says "ALTTIME" is not a valid function.
Thanks,
Siva |
|
Back to top |
|
|
wanderer
Active User
Joined: 05 Feb 2007 Posts: 199 Location: Sri Lanka
|
|
|
|
Check in SYSIBM.SYSROUTINES for an entry of ALTTIME function with DSN8. It is probably not there. You can talk to your DBAs to make that available.
Otherwise, as far as I understand, DB2 doesn't have any builtin function that can take in a time format like HH:MM:SS AM/PM
There is one HH:MM AM/PM however, if you are willing to sacrifice the 'SS'. |
|
Back to top |
|
|
Sivagurunathan Jagadeesan
New User
Joined: 06 Mar 2007 Posts: 32 Location: India
|
|
|
|
Hi,
Thanks for your inputs, I'll check in SYSROUTINES.
Used a query like this,
EXEC SQL
SELECT
(RIGHT('00'||RTRIM(CHAR(HOUR(IN_TIME))),2) ||
'.' ||
RIGHT('00'||RTRIM(CHAR(MINUTE(IN_TIME))),2) ||
'.' ||
RIGHT('00'||RTRIM(CHAR(SECOND(IN_TIME))),2))
END-EXEC.
The INTIME is in HH:MM:SS AM/PM format, above query converts it to 24hrs format.
Thanks,
Siva |
|
Back to top |
|
|
wanderer
Active User
Joined: 05 Feb 2007 Posts: 199 Location: Sri Lanka
|
|
|
|
Hmm..the HOUR function is not supposed take a TIME format with HH:MM:SS AM/PM as input as far as the manual says. But then if it works for you, great!
And thanks to you, I tried out the ALTTIME function. |
|
Back to top |
|
|
|