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!

Concantenating fields

Status
Not open for further replies.
Dec 11, 2009
60
US
I have 2 date fields that I want to concantenate to print as:

1/1/2010 to 2/2/2010. I have this code:

k.startdate+'to'+k.enddate as date

but get this error: Msg 241, Level 16, State 1, Line 6
Syntax error converting datetime from character string.

What am I not doing?

Thanks!

 
You need to convert each of the dates to a string first.

Convert(VarChar(10), K.StartDate, 101) + ' to ' + Convert(VarChar(10), K.EndDate, 101)



-George

"The great things about standards is that there are so many to choose from." - Fortune Cookie Wisdom
 
Code:
CONVERT(VARCHAR(20), k.startdate, 101) +'to'+ CONVERT(VARCHAR(20), k.enddate, 101) as date
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top