One minute precision of SMALLDATETIME

The precision of the data type SMALLDATETIME in SQL Server is 1 minute, seconds are discarded, and minutes are rounded up or down as you can see in the example:

DECLARE @DateTime AS SMALLDATETIME
SET @DateTime = '2012-06-26 10:46:01'
SELECT @DateTime SmallDateTime_Value
SET @DateTime = '2012-06-26 10:46:29'
SELECT @DateTime SmallDateTime_Value
SET @DateTime = '2012-06-26 10:46:30'
SELECT @DateTime SmallDateTime_Value
SET @DateTime = '2012-06-26 10:46:42'
SELECT @DateTime SmallDateTime_Value
SET @DateTime = '2012-06-26 10:46:59'
SELECT @DateTime SmallDateTime_Value

As you can see, the value of the seconds is always displayed as value '00' in smalldatetime data type.

To be more accurate about rounding here is one more example:

DECLARE @DateTime AS SMALLDATETIME
SET @DateTime = '2012-06-26 10:46:29.998'
SELECT @DateTime SmallDateTime_Value
SET @DateTime = '2012-06-26 10:46:29.999'
SELECT @DateTime SmallDateTime_Value

In this example the SMALLDATETIME data type rounds the date to 2012-06-27, instead of 2012-06-26:

DECLARE @DateTime AS SMALLDATETIME
SET @DateTime = '2012-06-26 23:59:30'
SELECT @DateTime SmallDateTime_Value

If the post helped you, please share it:
Pin It

1 comment to One minute precision of SMALLDATETIME

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">