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 6603137
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T18:58:04+00:00 2026-05-25T18:58:04+00:00

Got following fields in table: Run Date : 2011-09-25 00:00:00.000 Run Time : 05:00:00

  • 0

Got following fields in table:

Run Date : 2011-09-25 00:00:00.000

Run Time : 05:00:00

Run Duration : 03:22:51

What I need is in Dateformat

Run Date + Run Time = Start Time of Job (DateTime Format)

Run Date + (Run Time + Run Duration) = End Time of Job (DateTime Format)

I’m struggling to do conversion. Can anyone please help.

This is the STORED PROCEDURE which I’m using – can anyone advise how to monitor this:

ALTER PROCEDURE [dbo].[Sp_listjobrunhistory] @dateparam DATETIME,
@JobName VARCHAR(100)
AS
BEGIN
SELECT –sysjobhistory.server,
sysjobs.name
AS
job_name,
CASE sysjobhistory.run_status
WHEN 0 THEN ‘Failed’
WHEN 1 THEN ‘Succeeded’
ELSE ‘???’
END
AS
run_status,
CAST(
Isnull(Substring(CONVERT(VARCHAR(8), run_date), 1, 4) + ‘-‘ +
Substring(CONVERT(VARCHAR
(8), run_date), 5, 2) + ‘-‘ +
Substring(CONVERT(VARCHAR(
8), run_date), 7, 2), ”) AS DATETIME)
AS
[Run DATE],

         Isnull(Substring(CONVERT(VARCHAR(7), run_time+1000000), 2, 2) + ':'
                 +
                       Substring(CONVERT(VARCHAR(7), run_time+1000000), 4, 2
                        )
                +
                ':' +
                Substring(CONVERT(VARCHAR(7), run_time+1000000), 6, 2), '') 
         AS
         [Run TIME],
         Isnull(Substring(CONVERT(VARCHAR(7), run_duration+1000000), 2, 2) +
                 ':' +
                       Substring(CONVERT(VARCHAR(7), run_duration+1000000),
                       4,
                       2)
                + ':' +
                Substring(CONVERT(VARCHAR(7), run_duration+1000000), 6, 2),
         ''
         ) AS
         [Duration],
         Isnull(Substring(CONVERT(VARCHAR(7), run_time+run_duration+1000000), 2, 2) + ':'
                 +
                       Substring(CONVERT(VARCHAR(7), run_time+run_duration+1000000), 4, 2
                        )
                +
                ':' +
                Substring(CONVERT(VARCHAR(7), run_time+run_duration+1000000), 6, 2), '')
         AS
         [Total TIME],             
         sysjobhistory.step_id,
         sysjobhistory.step_name,
         sysjobhistory.MESSAGE
  FROM   msdb.dbo.sysjobhistory
         INNER JOIN msdb.dbo.sysjobs
           ON msdb.dbo.sysjobhistory.job_id = msdb.dbo.sysjobs.job_id
  WHERE  sysjobhistory.run_date <= Datepart(yyyy, @dateparam) * 10000 +
                                         Datepart(mm, @dateparam) * 100 +
                                  Datepart
                                  (
                                         dd, @dateparam)
         AND sysjobs.name = @JobName --remove this line if you want to show all jobs for the specified day
  ORDER  BY instance_id DESC

END
Regards

  • 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-05-25T18:58:05+00:00Added an answer on May 25, 2026 at 6:58 pm

    In SQL Server 2008, no conversion is required.

    declare @T table
    (
      RunDate datetime,
      RunTime time,
      RunDuration time
    )
    
    insert into @T values('2011-09-25 00:00:00.000', '05:00:00', '03:22:51')
    
    select RunDate + RunTime as StartTimeOfJob,
           RunDate + RunTime + RunDuration as EndTimeOfJob
    from @T
    

    And in versions before 2008 it could be like this.

    declare @T table
    (
      RunDate datetime,
      RunTime varchar(8),
      RunDuration varchar(8)
    )
    
    insert into @T values(
    '2011-09-25 00:00:00.000',
    '05:00:00',
    '03:22:51')
    
    select RunDate + RunTime as StartTimeOfJob,
           RunDate + RunTime + RunDuration as EndTimeOfJob
    from @T
    

    Ooops. No conversions needed there either.

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

Sidebar

Related Questions

Need help, struggling to do this please Got the following fields in table Package_Name
I've got an organisation database table which holds the following fields: organisationid, organisationname, organisationaddressid,
I have the following problem: I got a view with two text fields and
I've got a table Employees with employees (say the important fields are ID int,
I've got the following query: SELECT name, GROUP_CONCAT(job SEPARATOR ','), count(*) FROM users GROUP
I have a MySQL table (table1) with following fields... id, title, description, detail, category,
I've got the following problem. My table ( geo_table ) structure is as follows:
I've got the following User model: class User < ActiveRecord::Base # Users table has
i've got the following request: create a plain text field that transforms into an
I've got the following question. I've got one class Instellingen that's a field in

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.