Consulting

Results 1 to 2 of 2

Thread: Concantenating two columns

  1. #1

    Concantenating two columns

    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.
    Last edited by spittingfire; 10-17-2015 at 08:41 AM.

  2. #2
    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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •