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

Combine 2 separate pieces of data and get single datetime? 1

Status
Not open for further replies.

glthornton

Programmer
Oct 19, 2005
108
0
0
US
Hi,

Is it possible to combine 2 separate date and time fields and then convert them to a single date/time format within a SELECT statement? Let me give you an example, I have one field called Appointment Date (apptDT) and then I have another field called Appointment Time (apptTM). This is what the field values would contain:

Code:
apptDT = '02/29/2008'
apptTM = '2:00 PM'

But what I would like for a result is:
Code:
2008-02-29 14:00:00.000

Is there a way I could perform this conversion within a SELECT statement?

Kind regards,
Glenn
 
[tt][blue]
Select Convert(DateTime, apptDT) + Convert(DateTime,apptTM) As apptDateTime[/blue][/tt]

This will fail if you have data that cannot be converted to a date time.


-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
You're awesome George!!! Sometimes things like this seem a lot harder than they really are. Thank you so much. You're a life saver!

Glenn
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top