Results 1 to 2 of 2

Thread: converting date formats

  1. #1
    KJC Guest

    converting date formats


    Hi,

    I need to convert the output of a query

    From:
    Sep 13 1999 12:00AM

    To:

    1999-09-13 00:00:00.000

    I need it to be in 7.0 format)

    Thanks.

  2. #2
    RamaKrishna Seelam Guest

    converting date formats (reply)

    Try this:
    If @date is the datetime variable containing the output use the following conversion:

    select convert(varchar(4),datepart(year,@date))+'-'+
    convert(varchar(2),datepart(mm,@date))+'-'+
    convert(varchar(2),datepart(dd,@date))+' '+
    convert(varchar(2),datepart(hh,@date))+':' +
    convert(varchar(2),datepart(mi,@date))+':' +
    convert(varchar(2),datepart(ss,@date))+'.' +
    convert(varchar(3),datepart(ms,@date))

    regards,
    Ramakrishna Seelam

    ------------
    KJC at 4/10/00 3:49:44 PM


    Hi,

    I need to convert the output of a query

    From:
    Sep 13 1999 12:00AM

    To:

    1999-09-13 00:00:00.000

    I need it to be in 7.0 format)

    Thanks.

Posting Permissions

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