DateTime doesnt display Seconds

  • I have this problem with seconds doesn't display in my smalldatetime column.

       select eventdate from tblLOG displays

        2004-05-06 08:52:00.000

     but when I do select getdate()

        2004-05-06 10:49:37.060

    I could not find why I don't get seconds from my frist query.

    Any help would be greately appreciated!

  • First off GETDATE() is inherently datetime as far as data type.

    Try

    select cast(getdate() as smalldatetime)

    and you will get the same results of not having seconds in the output.

    The reason is smalldatetime is only accurate down to the minute whereas datetime is accurate down to one three-hundredths of a second.

    See "datetime and smalldatetime" in SQL BOL for a more in depth overview.

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

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