Hello all, I have this script that is working except that in the hours, minutes and seconds fields when any of them have a leading zero the zero gets dropped. For instance: if a session has been running for 12 minutes and 7 seconds the output will display 0:12:7 instead of 00:12:07. A trailing zero is ok. Those get displayed. I suspect I have to do something with the decimal(2) but not sure what that might be yet so I thought I'd ask the experts.
Thanks!
select client_name, session_id, state, -
substr(cast((start_time) as char(29)),1,10) as "Start Date", -
substr(cast((start_time) as char(29)),12,8) as "Start Time", -
cast(float(bytes_sent/1024/1024) as dec(12,3)) as "MB Sent", -
cast(float(bytes_received/1024/1024) as dec(12,3)) as "MB Recvd", -
CAST((current_timestamp-start_time)hours as decimal(2))||':'|| -
CAST((current_timestamp-start_time)minutes as decimal(2))||':'|| -
CAST((current_timestamp-start_time)seconds as decimal(2)) as "ELAPTIME HH:MM:SS" -
from sessions order by session_id
Thanks!
select client_name, session_id, state, -
substr(cast((start_time) as char(29)),1,10) as "Start Date", -
substr(cast((start_time) as char(29)),12,8) as "Start Time", -
cast(float(bytes_sent/1024/1024) as dec(12,3)) as "MB Sent", -
cast(float(bytes_received/1024/1024) as dec(12,3)) as "MB Recvd", -
CAST((current_timestamp-start_time)hours as decimal(2))||':'|| -
CAST((current_timestamp-start_time)minutes as decimal(2))||':'|| -
CAST((current_timestamp-start_time)seconds as decimal(2)) as "ELAPTIME HH:MM:SS" -
from sessions order by session_id