473,395 Members | 1,720 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

DateTime Data Types and SQL Server NULL

Any suggestions on how to track a NULL value received from SQL Server in a
DateTime field? I have come up with two and I'm not convinced either of them
are good solutions.

1. Assign a predetermined value (DateTime.Date.MaxValue... or something like
that) in place of NULL and check for that when necessary. Seems a little
Y2K-ish to me.

2. Use a companion Boolean variable (e.g. bool dateIsNull) to track the
status. Not such a bad idea but seems tedious to keep them in sync.

On a side note, I have some data architecture/ADO.NET/SQL Server/C# concerns
I would like to discuss with someone or a group of someones ;). Any
suggestions? (I know, that may be a little too specific, but there doesn't
seem to be a newsgroup that would apply without possibly offending someone
and I really don't want to cross-post.)

TIA - Eric
Nov 15 '05 #1
1 7461
Box your values on the way in and out of the database in an object...
either the "object" type or one of your own creation... and handle the
change over manually. I use my own boxing types and provide a
".ToValueOrNull()" method that... in the case of dates... provides a
dbnull if the date it contains is a pre-set bogus date (jan 1, 1901),
etc.

"E. R. Retzloff" <eretzloff_at_hotmail_dot_com> wrote in message news:<#h**************@tk2msftngp13.phx.gbl>...
Any suggestions on how to track a NULL value received from SQL Server in a
DateTime field? I have come up with two and I'm not convinced either of them
are good solutions.

1. Assign a predetermined value (DateTime.Date.MaxValue... or something like
that) in place of NULL and check for that when necessary. Seems a little
Y2K-ish to me.

2. Use a companion Boolean variable (e.g. bool dateIsNull) to track the
status. Not such a bad idea but seems tedious to keep them in sync.

On a side note, I have some data architecture/ADO.NET/SQL Server/C# concerns
I would like to discuss with someone or a group of someones ;). Any
suggestions? (I know, that may be a little too specific, but there doesn't
seem to be a newsgroup that would apply without possibly offending someone
and I really don't want to cross-post.)

TIA - Eric

Nov 15 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Manish Jain | last post by:
Platform : ASP.Net/C# void SomeFunction(DateTime date) { string text = date.ToString(); //This crashes if date is null } I am using a construct similar to above. I want to check if the date...
2
by: nic | last post by:
hey, I always struggle with the following: I have an object obj with a property paydate (type = DateTime) Now, after instantiating the object and do several things, I want too check if my...
2
by: Fabiano | last post by:
Please, i have an webform, that work with a object that receives a DateTime value. I don't want to save date into it. How can i verify if it's value is null or not? Tks Fabiano
6
by: Paulb1us | last post by:
I want to set a DateTime field to Null before passing it to the DB //First I check to see if anything is in this datarow column, because sometimes we have no data. DateTime dt; if (...
9
by: Phil B | last post by:
I am having a problem with a datetime from a web services provider The provider is sending the following SOAP response <?xml version="1.0" encoding="utf-8"?> <soap:Envelope...
5
by: ns21 | last post by:
Our application is windows desktop application. We are using VS.Net 2003, C#, Framework 1.1, SQL 2000. We use webservices to add/update/select objects. We are using XML Serialization. Following is...
4
by: Lucvdv | last post by:
I have to connect to a server set up by the government, where they used Apache Axis to create a webservice. The code I use to interface to the webservice is generated by wsdl.exe, based on a...
1
by: suslikovich | last post by:
Hi all, I am getting this error when insert values from one table to another in the first table the values are varchar (10). In the second they are datetime. The format of the data is mm/dd/yyyy...
4
by: =?Utf-8?B?QmFidU1hbg==?= | last post by:
Hi, I have a GridView and a SqlDataSource controls on a page. The SqlDataSource object uses stored procedures to do the CRUD operations. The DataSource has three columns one of which -...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.