473,804 Members | 2,194 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Input null into a DateTime property.

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
Nov 16 '05 #1
2 1879
Hi,

Please clarify more your problem.
Just remember something, DateTime does not support null, you would have to
select an extreme value like ,DateTime.MinVa lue to represent null
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Fabiano" <a@a.com.br> wrote in message
news:eT******** *****@tk2msftng p13.phx.gbl...
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

Nov 16 '05 #2
Ah, the standard "magic value" approach. Unforunately, this is a core
problem that Microsoft is getting closer to solving with Nullable types in
..NET 2.0.

However, in .NET 1.x, you have three main solutions:

1. The Ostrich Approch - Basically make all your DateTime fields
non-nullable and put your head in the sand with regards to the existence of
"unknown" date time values.

2. The "Magic Value" Approach that Ignacio mentioned. In this scenario you
pick a "magic value" for the given data type to represent an "unknown"
value. This approach has numerous caveats. The first is that if your system
is ever required to integrate with someone else's system who used a
different magic value, you will have problems. In addition, if that "magic
value" ever becomes a real value, you will have a bunch of work to do to
make a new "magic value." Lastly, it will be inordinately difficult on new
developers and report writers that come in when they have to have the "holy
magic value" list for every field (since some fields may have different
magic values).

3. The "I live in a world based on reality and am using .NET 1.x"
You have two subchoices here. One is to the SqlTypes. They allow for nulls
and are generally handled most places in ASP.NET. The problem with SqlTypes
is that they are not serializable. So if that is at all a possible need, you
have to move to the second choice. The second choice is to build your own
nullable type that mimics the primitives but allows for nulls (e.g. DBInt32,
DBInt16, DBDateTime etc.) This is more of a pain to be sure, but does allow
you to handle any sort of null as well as to store actual nulls in the
database.
I really wish Microsoft would build more database driven enterprise systems
that actually have database nulls and use business objects in the middle
tier. Were they to do that, they would realize that nulls need to propogate
all the way to the presentation layer as Fabiano has discovered.

Thomas

"Ignacio Machin ( .NET/ C# MVP )" <ignacio.mach in AT dot.state.fl.us > wrote
in message news:uI******** ******@tk2msftn gp13.phx.gbl...
Hi,

Please clarify more your problem.
Just remember something, DateTime does not support null, you would have
to
select an extreme value like ,DateTime.MinVa lue to represent null
Cheers,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Fabiano" <a@a.com.br> wrote in message
news:eT******** *****@tk2msftng p13.phx.gbl...
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


Nov 16 '05 #3

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

Similar topics

9
548
by: news.microsoft.com | last post by:
Hello, I have DateTime property. How can I set this value to null?
2
24678
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 in the xml.
7
2616
by: MP | last post by:
Hello, I am trying to write a class that will expose some properties. One of the property is extracted from a SQL database and can be NULL or some integer value. Is there a elegant way of implementing this in C# ? I do not want to use variant (or similar types) because I want to retain a strnong types property. Will I have no choices but to add another property that would set/get the NULL value?
6
10087
by: evolve | last post by:
why doesn't c# seem to support some kind of 'null date' for instance: i have an application where the user is not obliged to enter a date until an event happens (e.g. a bug was fixed on xyz) the calendar control in asp.net doesn't seem to have a selectedDate = null property
6
6528
by: Markus Eßmayr | last post by:
Hello, I'd like to consume a WebService, which returns an array of objects which include several members of type System.String, System.Decimal and System.DateTime. In the WSDL-file, the members of the object are marked as nilable. I generated the client classes using VS.NET 2003. After the creation, I got the class-definition of the objects returned by the WebService too. BUT, only the System.String members where marked to be nullable,...
11
16424
by: Mark Rae | last post by:
Hi, I have a class with several properties, one of which is of the DateTime datatype. However, this property will not always have a value, and I need to check later whether it has a value or not. When I create a new instance of the class, this property acquires a default value of {1/1/1}, which I don't want at all, as that is a perfectly valid date.
3
1928
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 return null; because "Cannot convert null to 'System.DateTime' because it is a value type" How can this be done?
5
6347
by: TheSteph | last post by:
Hi ! I have a DataGridView with a Date (DateTime) Column. When a user edit the cell and change the date I woulk like to allow him to write "081501" and programmatically transform the entered date to "2008/15/01"( using a custom method called TransformDate(string ARawDate)) But I can't find any DataGridView event to call the TransformDate method and replace the user input by the computed value. I always get a "DataError".
0
2604
by: tschroeder250 | last post by:
Hi Everyone, There are so many Nullable DateTimePickers out there that this post may not even be found among all the others, but I wanted to try. First, I want to thank all the authors of the code I used as a starting point. Second, I hope this code helps someone as much as they helped me. I have built a Nullable DateTimePicker and NullableCalendarColumn/Cell/EditingControl that is nearly 100% complete, as far as I can tell. There is...
0
9715
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9595
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10603
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
10356
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9176
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7643
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
6869
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
4314
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3836
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.