Datetime imprecision

  • Hi,

    Why do I get '2007-03-01 00:00:00' for

    select convert(smalldatetime,left(convert(varchar,getdate(),120),10) + ' 23:59:59')

    same with

    select convert(datetime,dateadd(ms ,-1,left(convert(varchar,(getdate() + 1),120),10) +' 00:00:00'))

    or try this

    create table test

    (

    aa smalldatetime

    )

    insert into test

    values('2007-03-01 23:59:59')

    select * from test = '2007-03-01 00:00:00' ??????

    Why can i not create the precision i require!!!!

  • This is all in BOL.

    Smalldatetime is rounded to the nearest minute.

    Milliseconds in datetime are rounded to 0, 3 or 7.

     

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

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