Simple Question - Does SQL Server 2005 Allows NULL for DateTime?

  • Thread starter Thread starter jehugaleahsa
  • Start date Start date
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.
 
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.
 
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
 
If the database table is set up that way? Yes.

--
Gregory A. Beamer
MVP, MCP: +I, SE, SD, DBA

*************************************************
| Think outside the box!
|
*************************************************
 
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
 
Jon Skeet said:
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.
 
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
 
Jon Skeet said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top