In an SP how do we concatenate two fields | SQL Server Performance Forums

SQL Server Performance Forum – Threads Archive

In an SP how do we concatenate two fields

Hi All, In an SP how do we concatenate two fields.
eg: i have 2 date fields and i want the result as ‘date1-date2’ How do I go about it? Sitanshu Gupta
Where do you want to show the concatenated dates? Madhivanan Failing to plan is Planning to fail
no. i dont want the diff i want 23/01/2006-24/01/2006 Sitanshu Gupta
use cast or convert( varchar… to change the dates to a character datatype and then concat convert( varchar(10), @date1 ) + ‘-‘ + convert( varchar(10), @date2 ) if necessary use the optional third parameter of the convert function to change the format of the date Cheers
Twan
select convert(varchar,getdate(),101)+’-‘+convert(varchar,getdate()+2,101) Madhivanan Failing to plan is Planning to fail
Still not clear what you want – do you want the two dates printed with a ‘-‘ character in betweeen (=concatenation) or do you want to see the number of milliseconds/seconds/minutes/hours/days/weeks/months/years between the two dates (=DATEDIFF calculation)?
the concatenation i have clearly mentioned that. Sitanshu Gupta
It looked like perhaps you didn’t know what "concatenate" meant. Apologies.
no probs, but thanks for giving me the correct ans. its working with Madhivanan’s reply. thanks guys. Sitanshu Gupta
But still you didnt tell us where you want to show these concatenated dates? Madhivanan Failing to plan is Planning to fail
]]>