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
 combine 2 columns to get date time

Author  Topic 

gator8869
Starting Member

37 Posts

Posted - 2007-08-28 : 13:15:32
adate atime
08-21-2007 11:09
08-20-2007 16:49
08-03-2007 00:39

I would like to combine adate with atime to get adatetime

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-28 : 13:17:00
SET DATEFORMAT DMY

SELECT CAST(aDate + ' ' + aTime AS SMALLDATETIME)
FROM Table1



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2007-08-28 : 13:17:52
Is this related to this problem?
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=88487



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

dinakar
Master Smack Fu Yak Hacker

2507 Posts

Posted - 2007-08-28 : 13:17:56
SELECT Convert(datetime,adate + ' ' + atime)

Dinakar Nethi
************************
Life is short. Enjoy it.
************************
http://weblogs.sqlteam.com/dinakar/
Go to Top of Page

gator8869
Starting Member

37 Posts

Posted - 2007-08-28 : 13:29:23
Thank you...brand new to SQL programming
Go to Top of Page

jsmith8858
Dr. Cross Join

7423 Posts

Posted - 2007-08-28 : 14:04:54
If you use correct data types for your dates and times, you can just add them together. So converts, no string formats, no concatenation.

select adate + atime
from yourtable

Always, always use the correct data types for your data.

- Jeff
http://weblogs.sqlteam.com/JeffS
Go to Top of Page
   

- Advertisement -