Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Datetime Conversion

Author  Topic 

sagitariusmzi
Posting Yak Master

113 Posts

Posted - 2010-03-26 : 07:45:56

SELECT run_date,run_time FROM msdb.dbo.sysjobhistory

results from the above query

run_date run_time
20100325 123253
20100325 123252
20100325 123319
20100325 123319

How to convert it in datetime
i used Cast(convert(varchar, run_date,112) As datetime) for date portion but unable to concate time with it

Transact Charlie
Master Smack Fu Yak Hacker

3451 Posts

Posted - 2010-03-26 : 08:05:58
Well -- this is one way....

SELECT
run_date
, run_time

, DATEADD(SECOND, run_time % 100,
DATEADD(MINUTE, (run_time / 100) % 100,
DATEADD(HOUR, (run_time / 10000),
CAST(CAST(run_date AS CHAR(8)) AS DATETIME )
)
)
)
FROM
msdb.dbo.sysjobhistory



Charlie
===============================================================
Msg 3903, Level 16, State 1, Line 1736
The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION
Go to Top of Page
   

- Advertisement -