Does SQL Server 2005 Allows NULL for DateTime? Just checking.
Lasse Vågsæther Karlsen - 26 Feb 2008 15:44 GMT
> Does SQL Server 2005 Allows NULL for DateTime? Just checking.
SQL Server 2005 allows NULL for any data type to my knowledge, you flag
this as an additional option on the column, wether to allow NULL or not.

Signature
Lasse Vågsæther Karlsen
mailto:lasse@vkarlsen.no
http://presentationmode.blogspot.com/
PGP KeyID: 0xBCDEA2E3
Jon Skeet [C# MVP] - 26 Feb 2008 15:46 GMT
> Does SQL Server 2005 Allows NULL for DateTime? Just checking.
Yes, so long as your column is nullable.

Signature
Jon Skeet - <skeet@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
World class .NET training in the UK: http://iterativetraining.co.uk
Alberto Poblacion - 26 Feb 2008 15:46 GMT
> Does SQL Server 2005 Allows NULL for DateTime? Just checking.
Yes, SQL Server alows it. On the other hand, .Net does not (DateTime in
.Net is a Value Type) so be careful when designing your client code to
receive the DateTime values returned from Sql Server.
Jon Skeet [C# MVP] - 26 Feb 2008 15:53 GMT
On Feb 26, 3:46 pm, "Alberto Poblacion" <earthling-
quitaestoparacontes...@poblacion.org> wrote:
> > Does SQL Server 2005 Allows NULL for DateTime? Just checking.
>
> Yes, SQL Server alows it. On the other hand, .Net does not (DateTime in
> .Net is a Value Type) so be careful when designing your client code to
> receive the DateTime values returned from Sql Server.
Well, so long as you're not using .NET 1.1 there's the fairly obvious
choice of Nullable<DateTime> (aka "DateTime?").
Jon
Paul E Collins - 27 Feb 2008 10:47 GMT
> Well, so long as you're not using .NET 1.1 there's the fairly obvious
> choice of Nullable<DateTime> (aka "DateTime?").
SqlDateTime is a bit safer because its MinValue and MaxValue match those
of SQL Server.
Eq.
Jon Skeet [C# MVP] - 27 Feb 2008 11:10 GMT
On Feb 27, 10:47 am, "Paul E Collins" <find_my_real_addr...@CL4.org>
wrote:
> > Well, so long as you're not using .NET 1.1 there's the fairly obvious
> > choice of Nullable<DateTime> (aka "DateTime?").
>
> SqlDateTime is a bit safer because its MinValue and MaxValue match those
> of SQL Server.
On the other hand, that leaks the database nature of it into the rest
of the code. I prefer to have my entity code non-database-specific.
I also tend to avoid using MinValue and MaxValue in the first place,
as they're rarely useful values. Point taken that it's nice to have
them aligned on occasion though.
Jon
Paul E Collins - 27 Feb 2008 17:55 GMT
> I also tend to avoid using MinValue and MaxValue in the first place,
> as they're rarely useful values.
Yes, I suppose I only ever used MinValue as a "no date" flag before C#
had nullable structs.
Eq.
jehugaleahsa@gmail.com - 26 Feb 2008 16:16 GMT
On Feb 26, 8:38 am, "jehugalea...@gmail.com" <jehugalea...@gmail.com>
wrote:
> Does SQL Server 2005 Allows NULL for DateTime? Just checking.
Thanks.
Cowboy (Gregory A. Beamer) - 26 Feb 2008 16:53 GMT
If the database table is set up that way? Yes.

Signature
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA
*************************************************
| Think outside the box!
*************************************************
> Does SQL Server 2005 Allows NULL for DateTime? Just checking.
Arne Vajhøj - 27 Feb 2008 01:29 GMT
> Does SQL Server 2005 Allows NULL for DateTime? Just checking.
I am pretty sure that all relational databases by definition has to
support NULL for all data types.
Arne