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

DateTime to null

How do I set a DateTime field to null ?
Hence set the DateTimePicker to null?
Jul 18 '06 #1
4 5633
Hello Alan,

You can't really. You can assign DbNull, but DateTime is a valuetype, therefore
no null...
Thanks,
Shawn Wildermuth
Speaker, Author and C# MVP
http://adoguy.com
How do I set a DateTime field to null ?
Hence set the DateTimePicker to null?

Jul 18 '06 #2
"Shawn Wildermuth (C# MVP)" <sw*********@newsgroup.nospama écrit dans le
message de news: fc*************************@msnews.microsoft.com...

| How do I set a DateTime field to null ?
| Hence set the DateTimePicker to null?
|
| You can't really. You can assign DbNull, but DateTime is a valuetype,
therefore
| no null...

But, if you are using C# 2.0, you can use Nullable<DateTimewhich can be
set to null and you can detect that, setting the database to DbNull where
appropriate.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer
Jul 18 '06 #3
Hi,

Will the DateTimePicker accept nullable types?
AFAIK it does expect a DateTime.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Joanna Carter [TeamB]" <jo****@not.for.spamwrote in message
news:OP**************@TK2MSFTNGP03.phx.gbl...
"Shawn Wildermuth (C# MVP)" <sw*********@newsgroup.nospama écrit dans le
message de news: fc*************************@msnews.microsoft.com...

| How do I set a DateTime field to null ?
| Hence set the DateTimePicker to null?
|
| You can't really. You can assign DbNull, but DateTime is a valuetype,
therefore
| no null...

But, if you are using C# 2.0, you can use Nullable<DateTimewhich can be
set to null and you can detect that, setting the database to DbNull where
appropriate.

Joanna

--
Joanna Carter [TeamB]
Consultant Software Engineer


Jul 18 '06 #4

Ignacio Machin ( .NET/ C# MVP ) wrote:
Hi,

Will the DateTimePicker accept nullable types?
AFAIK it does expect a DateTime.
See this link, under DateTimePicker:

http://msdn.microsoft.com/netframewo...ffaq/wf20.aspx

Jul 18 '06 #5

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

Similar topics

9
by: news.microsoft.com | last post by:
Hello, I have DateTime property. How can I set this value to null?
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...
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...
1
by: Dean L. Howen | last post by:
Dear friends, Could you help me to solve the problem: How can we set/get NULL values of datetime in DatetimePicker ? I design a form using DateTimePicker to input/output date value, but the date...
2
by: Rey | last post by:
Howdy all. My problem deals w/inserting nulls into database (SQL Svr 2K) for the datetime fields activityDate and followUpDate where nulls are allowed. >From the web form, the user can type...
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...
3
by: Daves | last post by:
a get { ... } for public property SelectedValue returns DateTime type to be used as a parameter in a Sql update query but I'd like it to return "empty" if no date has been selected... I cannot use...
5
by: GG | last post by:
I am trying to add a nullable datetime column to a datatable fails. I am getting exception DataSet does not support System.Nullable<>. None of these works dtSearchFromData.Columns.Add( new...
9
by: Tony Van | last post by:
They're driving me nuts, especially with the Datareader. There are times when I want to pass a null date on to a date variable and I have to cast the null as a date!!!??? I'm wondering if I...
4
by: Bill Gower | last post by:
Why won't this work? What do I need to do to make it work? DateTime? DateMember; if((DateTime.Parse(oldRow.ToString) == null)) DateMember = null; else DateMember =...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.