Need T-SQL to render timestamp with NO special characters

  • Need 2008-10-17 08:44:56.123 rendered as: 20081017084456123

    (the milliseconds are optional.. this would also suffice: 20081017084456)

    thx

    BT
  • the built in convert functions can give you the format you want: you'd end up with a varchar containing all the inf....is that goo?

    select convert(varchar,getdate(),112) ,

    convert(varchar,getdate(),114),

    replace(convert(varchar,getdate(),112) + convert(varchar,getdate(),114),':','')

    2008101708:57:54:45320081017085754453

    DBASkippack (10/17/2008)


    Need 2008-10-17 08:44:56.123 rendered as: 20081017084456123

    (the milliseconds are optional.. this would also suffice: 20081017084456)

    thx

    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!

  • Lowell -- EXACTLY what I needed!

    select replace(convert(varchar,getdate(),112) + convert(varchar,getdate(),114),':','')

    Thanks a million..

    BT

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

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