﻿<?xml version='1.0' encoding='UTF-8'?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/"><channel><title>SQLServerCentral / Article Discussions / Article Discussions by Author / Discuss content posted by Rahul Kr. Ghosh  / smalldatetime / Latest Posts</title><generator>InstantForum.NET v2.9.0</generator><description>SQLServerCentral</description><link>http://www.sqlservercentral.com/Forums/</link><webMaster>notifications@sqlservercentral.com</webMaster><lastBuildDate>Fri, 24 May 2013 17:43:09 GMT</lastBuildDate><ttl>20</ttl><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>I cannot recall ever using smalldatetime, and now this QOD gives me good reason to avoid it.  A max value in year 2079 implies that anyone attempting to save a few bytes per row with this datatype may be leaving a Y2K-like mess for a future programmer or DBA to clean up.</description><pubDate>Wed, 05 Jan 2011 19:59:10 GMT</pubDate><dc:creator>john.arnott</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>@rejipr1982: Hugo already mentioned this in his response. Still thanks to evaluate the same.</description><pubDate>Tue, 04 Jan 2011 22:00:54 GMT</pubDate><dc:creator>Hardy21</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>Thanks for the question.The default value for the @date1 is NULL.Please see below proof. If I am commenting the 'set statement, I am  getting @date1 as NULL.declare @date1 smalldatetime--set @date1 = 0print Isnull(@date1,getdate())Thanks.Reji P RHyderabad</description><pubDate>Tue, 04 Jan 2011 11:21:12 GMT</pubDate><dc:creator>Reji PR</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>"Whenever we use any data type we should know it's default value"I disagree (even ignoring the valid but slightly pedantic points about datatypes not having defaults).We should never rely on default values in this way, it is prone to error, and hard to read the code.If you want to assign a value to a date variable, then explicitly assign the value you want, don't give it a value of a different datatype and rely on implict conversion :-)</description><pubDate>Tue, 04 Jan 2011 03:15:56 GMT</pubDate><dc:creator>Toreador</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>Nice question, terrible explanation.  SQL doesn't even have a concept of default values for its various datatypes.</description><pubDate>Mon, 03 Jan 2011 10:41:11 GMT</pubDate><dc:creator>L' Eomot Inversé</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>Thanks for the question, and thanks Hugo for your explanation.This question was really easy, as I knew the errors couldn't happen as they were stated, so there was only one option left.</description><pubDate>Thu, 30 Dec 2010 11:55:46 GMT</pubDate><dc:creator>UMG Developer</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>When a variable is declared in SQL by default it's value will be NULL, there is no default value concept in SQL variable declaration.RegardsKiran</description><pubDate>Wed, 29 Dec 2010 11:04:21 GMT</pubDate><dc:creator>kiran_gowda81</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>Thanks for the question and thanks to Hugo for the explanation.</description><pubDate>Wed, 29 Dec 2010 09:39:39 GMT</pubDate><dc:creator>SQLRNNR</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>[quote]Whenever we use any data type we should know it's default value[/quote]Although I will agree that knowing these things has value, I am more of the opinion of never leave anything to default, declare everything.  This way the default becomes irrelevant and you are much less likely to get a surprise in your results.</description><pubDate>Wed, 29 Dec 2010 07:34:50 GMT</pubDate><dc:creator>Daniel Bowlin</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>Nice, easy question. And thanks to Hugo for the extra, thorough explanation.</description><pubDate>Wed, 29 Dec 2010 07:31:27 GMT</pubDate><dc:creator>Koen Verbeeck</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>Great question.I didn't know it beforehand, but it sure made sense when I thought the question over.</description><pubDate>Wed, 29 Dec 2010 07:11:15 GMT</pubDate><dc:creator>Scott Arendt</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>Well that's what I get for second-guessing myself.  It seemed like such an easy question, the obvious answer couldn't possibly have been right.  Guess that'll teach me! ;-)Ron</description><pubDate>Wed, 29 Dec 2010 05:40:21 GMT</pubDate><dc:creator>ronmoses</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>Good (if fairly easy) question, but bad explanation.The default for smalldatetime is not Jan 1, 1900; it is NULL. Here is the proof:[code="sql"]DECLARE @d1 smalldatetime;SELECT @d1;[/code]Also, setting a variable to 0 is not at all requesting to set it to the default, it is requesting to set ot to the value 0, or whatever is the result of implicitly converting 0 to the data type of the variable.[code="sql"]DECLARE @v0 float, @v1 char(20), @v2 varbinary(max), @v3 xml, @v4 uniqueidentifier;-- Show default values - NULL for all data typesSELECT @v0, @v1, @v2, @v3, @v4;-- Set to result of implicit conversion of 0 to specified data typeSET @v0 = 0;SET @v1 = 0;SET @v2 = 0;-- Uncomment to get conversion errors--SET @v3 = 0;--SET @v4 = 0;-- Show resultsSELECT @v0, @v1, @v2, @v3, @v4;[/code]</description><pubDate>Wed, 29 Dec 2010 05:08:34 GMT</pubDate><dc:creator>Hugo Kornelis</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>Not so sure about the explanation given--smalldatetime doesn't have a "default value" of 1 Jan 1900, it's just that the underlying number that stores the date uses 0 to represent that date.</description><pubDate>Wed, 29 Dec 2010 02:17:06 GMT</pubDate><dc:creator>paul.knibbs</dc:creator></item><item><title>RE: smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>Nice question.</description><pubDate>Tue, 28 Dec 2010 22:05:44 GMT</pubDate><dc:creator>Hardy21</dc:creator></item><item><title>smalldatetime</title><link>http://www.sqlservercentral.com/Forums/Topic1040101-2866-1.aspx</link><description>Comments posted to this topic are about the item [B]&lt;A HREF="/questions/T-SQL/71910/"&gt;smalldatetime&lt;/A&gt;[/B]</description><pubDate>Tue, 28 Dec 2010 22:03:22 GMT</pubDate><dc:creator>Rahul The Dba</dc:creator></item></channel></rss>