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 Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date + Time 1

Status
Not open for further replies.

drlex

Technical User
Jul 3, 2002
3,295
GB
On the basis that your time is based on 1st Jan 1900 origin, I'd take the number of days since then from your date field and add them to the time field.

Code:
select dateadd(dd,datediff(dd,0,'2011-10-14 00:00:00.000'),'1900-01-01 09:00:00.000')

soi là, soi carré
 
1900-01-01 is the zero date, you so you could simply add the two columns together, like this:

Code:
declare @Temp Table([date] DateTime, StartTime DateTime)

Insert Into @Temp Values('2011-10-14', '09:00')

Select [date], StartTime, [date] + StartTime As NewDate
From @Temp

-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
 
George, how logical! And to think the OP had the answer in his question title "Date + Time". Star from me!

soi là, soi carré
 
[bigsmile]

-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
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top