Convert Datetime to TIME

  • hi I have the following query it works with SQL2008 servers as TIME is a validate data type....but on SQL-2005 it fails can you help change the syntax for 2005 servers please:

    cast((select top 1 ISNULL(stop_execution_date, GETDATE()) - start_execution_date

    FROM [msdb].[dbo].[sysjobactivity]

    where job_id = r.job_id

    order by start_execution_date desc) as time) as Job_Duration,

    thanks for looking

  • 1. The TIME datatype does not exist in 2005 (it was introduced it 2008)

    2. Your query appears to have been cut off.

    "I cant stress enough the importance of switching from a sequential files mindset to set-based thinking. After you make the switch, you can spend your time tuning and optimizing your queries instead of maintaining lengthy, poor-performing code."

    -- Itzik Ben-Gan 2001

  • it has been cut off...I needed help with it....I am aware of the DATA type in 2008 hence the help required for 2005

    anyway resolved for anybody who would need it:

    CONVERT(VARCHAR(12), (select top 1 ISNULL(stop_execution_date, GETDATE()) - start_execution_date

    FROM [msdb].[dbo].[sysjobactivity]

    where job_id = r.job_id

    order by start_execution_date desc), 14) AS Job_Duration ,

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply