Request

select LTRIM(RUN_DURATION ) from SYS.USER_SCHEDULER_JOB_RUN_DETAILS WHERE LOG_ID = 218737; 

returns: +000 00:01:27. I need only seconds from 0 to 59 - the last two characters

Himself guessed only to TRIM

 select LTRIM(RUN_DURATION , '+000 00:00')) from SYS.USER_SCHEDULER_JOB_RUN_DETAILS WHERE LOG_ID = 218737; 

But the value of the minutes may be different and this option does not suit me.

How to format the output to two characters on the right?

  • one
    If you are given an exhaustive answer, mark it as correct (a daw opposite the selected answer). - Nicolas Chabanovsky

2 answers 2

  select SUBSTR(RUN_DURATION,12) from SYS.USER_SCHEDULER_JOB_RUN_DETAILS ... 

We take characters starting from 12. If you need to cut out from the middle, then the third parameter substr can be set to the length.

  • Mike thanks! Exactly what is needed! - Pavel Mi

I think it would be better not to trim, but to use the extractor: select extract (second from run_duration)
from SYS.DBA_SCHEDULER_JOB_RUN_DETAILS;

  • Please try to write more detailed answers. I am sure the author of the question would be grateful for your expert commentary on the code above. - Nicolas Chabanovsky