concatenate string and datetime?

  • Hi Friends,

    I am trying to concatenate a string and datetime....i did it....but after concatenating , i am getting date and time like Jul 19 2012 7:18PM.

    i must get the datetime like 2012-07-19 19:21:01.587 + string value.

    is that possible?

    give me your suggestions friends

    Thanks,
    Charmer

  • Charmer (7/19/2012)


    Hi Friends,

    I am trying to concatenate a string and datetime....i did it....but after concatenating , i am getting date and time like Jul 19 2012 7:18PM.

    i must get the datetime like 2012-07-19 19:21:01.587 + string value.

    is that possible?

    give me your suggestions friends

    convert(varchar(22),MyDateTimeCol, 121) + ' ' + MyStringCol

  • i think you can use one of the built in convert formats.

    --2012-07-19 09:56:46.040 MyString

    SELECT CONVERT(VARCHAR,GETDATE(),121) + ' MyString'

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thank you Lowell, Lynn...

    I forgot the 121....

    Thanks,
    Charmer

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply