PDA

View Full Version : [SOLVED:] Concantenating two columns



spittingfire
10-17-2015, 08:28 AM
Hi All,

I am very new to the SQL world and trying my hands with a concatenation.

In column A I have data written in the format of 2015-03-28 00:00:00 000 and in column B I have data in the format of 123456789.

When I write the code

SELECT CONCAT(B1,'-',A1) FROM Tbl

I get a result of 123456789-Mar 28 2015 12:00AM

What I will like to get is 123456789-2015/03/28-00:00:00

In addition if I only want 123456789-2015/03/28 what will the code be?

Thanks in advance for all your help.

spittingfire
10-17-2015, 08:59 AM
After trying more options I came up with a solution.
SELECT
result1 = CONCAT(B1,'-',FORMAT(A1, 'yyyy/MM/dd-HH:mm:ss'))
,result2 = CONCAT(B1,'-',FORMAT(A1, 'yyyy/MM/dd'))
FROM #Tbl