Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Combine Date column with Time column 1

Status
Not open for further replies.

djj55

Programmer
Feb 6, 2006
1,761
US
Hello, SQL 2008 R2
I have a column of data type DATE and a column of data type TIME.

What is the best way to combine these two column to create a DATETIME column?

Did a search but cannot think of correct search criteria to use.

Thanks,

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
 
Convert each column to date time and add them together.

Ex:

Code:
Select Convert(DateTime, YourDateColumn) + Convert(DateTime, YourTimeColumn) As [DateTimeColumn]
From   YourTable


-George
Microsoft SQL Server MVP
My Blogs
SQLCop
"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Thank you! I had tried mydate + mytime which of course did not work.

By the way CAST will also work.

Thanks again,

djj
The Lord is my shepherd (Psalm 23) - I need someone to lead me!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top