Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8837801
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T09:49:15+00:00 2026-06-14T09:49:15+00:00

Using DB2 on the mainframe, I have a value indicating number of microseconds that

  • 0

Using DB2 on the mainframe, I have a value indicating number of microseconds that a job took, say 26,366,861,945.

Is there any easy way to get that into the H:MM:SS.mmmmmm format using standard DB2 functions? In other words, that value above would become 7:19:26.861945.

If necessary, we can drop the microseconds and accept HH:MM:SS.

If it’s over 24 hours, I’m not fussed about showing days, 27:02:14 would be fine.

I though about selecting the zero time plus xx microseconds but couldn’t get it to work.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T09:49:16+00:00Added an answer on June 14, 2026 at 9:49 am

    Well, it’s absolutely atrocious, but this should work:

    WITH
    
    ORIG (TS) AS (
        SELECT BIGINT(REPLACE('26,366,861,945', ',', ''))
        FROM SYSIBM.SYSDUMMY1
    ),
    
    CONV (TS) AS (
        SELECT TIMESTAMP_ISO('0001-01-01') + (SELECT TS FROM ORIG) MICROSECOND
        FROM SYSIBM.SYSDUMMY1
    ),
    
    FMT (TS) AS (
        SELECT VARCHAR_FORMAT(TS, 'DD-HH24:MI:SS.FF')
        FROM CONV
    ),
    
    DAYLOC (D) AS (
        SELECT LOCATE('-', TS)-1
        FROM FMT
    ),
    
    HOURLOC (H) AS (
        SELECT LOCATE(':', TS, (SELECT D FROM DAYLOC))-1
        FROM FMT
    ),
    
    DY (D) AS (
        SELECT CAST(SUBSTR(TS, 1, LOCATE('-', TS)-1) AS INTEGER)-1
        FROM FMT
    ),
    
    HOURS (H) AS (
        SELECT CAST(SUBSTR(TS, (SELECT D FROM DAYLOC)+2, 2) AS INTEGER)
        FROM FMT
    )
    
    SELECT 
        RTRIM(CHAR(((SELECT D FROM DY) * 24) + (SELECT H FROM HOURS))) ||
        SUBSTR(TS, (SELECT H FROM HOURLOC) +1)
    FROM FMT
    

    I split it into parts, so it should be fairly easy to follow. Convert the string to an integer, add that to a specific date (the date really doesn’t matter, as long as it’s the first of the month), then use some string searching / formatting to convert it to hours instead of days.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have to developed a project that is using DB2 and jRuby on rails.
I am using IBM DB2 with Toad. I have a stored procedure that I
I'm using DB2 v9 I have a stored procedure with paramaters that can potentially
i have problem using LIKE structure in DB2 : for example: select * from
I am using DB2 9.7 enterprise edition on Windows 7. I have created a
I have the same issue using hibernate against DB2 and MySQL. Here is a
When using the mainframe DB2 adapter for Microsoft BizTalk 2009, is there any way
I'm running an SQL query against a mainframe DB2 database using the OdbcDataReader class
I am using DB2 Express C 9.7.4 . I have to create connection with
I am using IBM DB2. I have a query which gives the output as:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.