473,396 Members | 1,847 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,396 software developers and data experts.

Assigning a Null to Datetime Variable or Object

Hi,

I need a solution to assign a Null to a Datetime Variable / Object.

Am willing to know whether it is possible?

I will appreciate you if any one knows the solution for it .

The Situation is

I like to store a Date in the Object when the User enters the Date.

If he doesn't enters anything then i like to store Null inorder to use that
in my Validation.

Note:
I have n't used the Date time Control for entering the Date rather i used
the Textbox to enter the Date. But the Object's Date Type is Datetime.

Let me know if anyone helps me

thanks
Solution Seeker
Nov 21 '05 #1
2 2389
Solution Seeker wrote:
I like to store a Date in the Object when the User enters the Date.
If he doesn't enters anything then i like to store Null inorder to
use that in my Validation.


I have approached this by using "DateTime.MinValue" as a placeholder for a
null date. Anywhere I want to store a blank date value in a Date variable,
I'll store DateTime.MinValue. Anywhere I want to check to see whether a date
is blank or not I'll compare it to DateTime.MinValue.

This has worked very well in my application.

Hope that helps,

--

(O)enone
Nov 21 '05 #2
"Solution Seeker" <Solution Se****@discussions.microsoft.com> schrieb:
I need a solution to assign a Null to a Datetime Variable / Object.


'Date' is a value type and cannot be 'Nothing'. Take a look at the
'SqlDateTime' data type, which supports 'NULL' values. .NET 2.0 will
support nullable types.

--
M S Herfried K. Wagner
M V P <URL:http://dotnet.mvps.org/>
V B <URL:http://classicvb.org/petition/>

Nov 21 '05 #3

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

Similar topics

1
by: GB | last post by:
Is there a function to set a null date in vb.net? Normally, I create a const NULLDATE = "1/1/1900", but that becomes a drag at times. Especially, handling a nulldate from SQL into a dataset. ...
7
by: Adrian Parker | last post by:
'function to convert null to nothing Function CheckDate(ByVal DRow As DataRow, ByVal strCol As String) As Date If DRow.Item(strCol) Is System.DBNull.Value Then Return Nothing Else Return...
11
by: Cor Ligthert | last post by:
Hello everybody, Jay and Herfried are telling me every time when I use CDate that using the datetime.parseexact is always the best way to do String to datetime conversions. They don't tell why...
20
by: weston | last post by:
I've got a piece of code where, for all the world, it looks like this fails in IE 6: hometab = document.getElementById('hometab'); but this succeeds: hometabemt =...
3
by: Reza Solouki | last post by:
Hello, I have a system where it gets its data from a file that is provided periodically. There are cases where many values such as dates are blank. Considering DateTime variable doesn't accept...
4
by: John | last post by:
Hi, I'm writing a database programme with C# using a dataset. I want to set a DateTime for a particular field of a row to null (nulls are allowed for that column). When I use: ...
5
by: AAJ | last post by:
Hi Does anyone know of any good publically available set of standards for managing dates when dealing with a database server (in my case SQL Server 2000 and c# VS2005). At the moment, if I...
2
by: Bill Gower | last post by:
How do I assign a null value to a datetime variable? DateTime DateNonMember = DateTime.Parse("").ToString(); This doesn't work. I also tried DateTime DateNonMember = DBNull.Value
1
by: Brad Pears | last post by:
I am using vb.net 2005 and SQL server 2000. In my table I have a date field of type "smalldatetime". In my vb application, the user may or may not enter a date value into the appropriate text box....
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
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...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.