473,326 Members | 2,010 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,326 software developers and data experts.

Assigning null value to DateTime

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
Bill
Feb 14 '07 #1
2 7112
Bill Gower <bi*******@charter.netwrote:
How do I assign a null value to a datetime variable?
You can't. DateTime is a value type, like int, char and boolean.
(That's not an exhaustive list!)

If you're using .NET 2.0, you can use DateTime? which is a nullable
version of DateTime. See
http://pobox.com/~skeet/csharp/csharp2/nullable.html for more
information.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet Blog: http://www.msmvps.com/jon.skeet
If replying to the group, please do not mail me too
Feb 14 '07 #2
Bill Gower schreef:
How do I assign a null value to a datetime variable?
DateTime DateNonMember = DBNull.Value

DateTime is a value type so you can't assign null to it.
You can assign null to Nullable<DateTime(DateTime? in c#)
--
Tim Van Wassenhove <url:http://www.timvw.be/>
Feb 14 '07 #3

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

Similar topics

2
by: Pet Matrix. | last post by:
Hi, I am having the schema and one element in that schema is , <xs:element name="EndT" type="TstampType" minOccurs="1" maxOccurs="1"/> How do I represent the NULL value for the datatype dateTime...
5
by: vince | last post by:
I want to assign a null value to a DateTime variable.How do i do that? Thanks Vince
8
by: craigkenisston | last post by:
I have a generic function that receives a couple of datetime values to work with. They can or cannot have a value, therefore I wanted to use null. This function will call a database stored...
6
by: FatboyCanteen | last post by:
When I using dataset to append a null value to the datetime field. It throw a error -> can not convert db.null to system.date Can there is any standard to pass a Null value to the DateTime...
4
by: Roy | last post by:
Hi all, How can I assign null to an integer. This doesn't work Dim intMyValue As Integer intMyVal = System.DBNull.Value Thanks in advance, Roy
12
by: GaryDean | last post by:
Is there any good way in which to deal with null datetimes. For instance, I can't seem to find anything that will pass a null value in a datetime parameter to another method. Convert.dbnull will...
1
by: seemabhatnagar | last post by:
How do i assign a null value to a textbox in asp.net using c#
2
by: preeti13 | last post by:
Hi guys i am here with my another probelm please help me.trying insert the value into the data base but getting the null value error .I am getting thsi error Cannot insert the value NULL into...
6
by: punitshrivastava | last post by:
Hi to All, I am Punit Shrivastava .I am working on Asp.net with C#.i am new in C#.I want to assign null or blank to a variable which is of float or int type.Please suggest me what i do. Thanks &...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...

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.