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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 issue with datetime field

Author  Topic 

joe8079
Posting Yak Master

127 Posts

Posted - 2013-09-16 : 15:31:00
Not sure why our database stores information like this, but here is the issue. When a job is closed out, it stores the actual date in field such as "ACTUAL DATE" from below and then it stores Time it was closed in another field such as "Actual Time with a Default Date"
Basically, I somehow need to combine the two so that it looks like the desired result below in bold. Has anyone ever seen this before in their enviroment?

Desired Result: 2013-08-22 13:09:57.000

Column1
Actual Date
2013-08-22 00:00:00.000

Column2
Actual Time with a default date
2013-08-01 13:09:57.000

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-09-16 : 15:56:57
Since you are on SQL 2008, you can make use of the TIME data type as follows:
SELECT [Actual Date] + CAST([Actual Time with a default date] AS TIME)
FROM YourTable
Go to Top of Page

joe8079
Posting Yak Master

127 Posts

Posted - 2013-09-16 : 16:09:52
thanks James! that worked. I appreciate your help
Go to Top of Page

James K
Master Smack Fu Yak Hacker

3873 Posts

Posted - 2013-09-16 : 17:41:07
You are very welcome - glad to help.
Go to Top of Page
   

- Advertisement -