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

DateTime null

JJ
Hi,

What's the correct code for checking if a DateTime control is empty or not
filled in with a date?

Thanks,

JJ
Nov 17 '05 #1
7 3835
JJ <JJ@discussions.microsoft.com> wrote:
What's the correct code for checking if a DateTime control is empty
or not filled in with a date?


Not sure what you mean by a DateTime control, as DateTime *isn't* a
control - however, there's no concept of a DateTime not being filled
in, any more than there is a concept of an int not being filled in. You
*may* be able to use a special value (eg DateTime.MinValue) as "not
provided" depending on your application.

Alternatively, you could encapsulate the DateTime in a reference type.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #2
Or, you could wait for v2.0 of the Framework, at which point you can
use "DateTime?"

Nov 17 '05 #3
JJ
ok the DateTimePicker Control is what i'm using if u want to get technical
about it.
I want to know if someone has not entered a date into it.

JJ

"Jon Skeet [C# MVP]" wrote:
JJ <JJ@discussions.microsoft.com> wrote:
What's the correct code for checking if a DateTime control is empty
or not filled in with a date?


Not sure what you mean by a DateTime control, as DateTime *isn't* a
control - however, there's no concept of a DateTime not being filled
in, any more than there is a concept of an int not being filled in. You
*may* be able to use a special value (eg DateTime.MinValue) as "not
provided" depending on your application.

Alternatively, you could encapsulate the DateTime in a reference type.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #4
mk
Incidentally, how would you set the value to null in the first place? I
would recommend that you handle the click or valuechanged event to indicate
user interaction.
BTW: The venerable Mr. Skeet was exactly right in pointing you towards
reference type, not to mention that he similar to the C# forum what
Alexander, Kim, Brian, and Igor are to the ATL forum (sorry
gurus-not-mentioned, I'm very bad on names). Suggesting that a person is
being too technical in a technical forum may be ill-received by some people.
Best regards.

HTH,

mk

"JJ" wrote:
ok the DateTimePicker Control is what i'm using if u want to get technical
about it.
I want to know if someone has not entered a date into it.

JJ

"Jon Skeet [C# MVP]" wrote:
JJ <JJ@discussions.microsoft.com> wrote:
What's the correct code for checking if a DateTime control is empty
or not filled in with a date?


Not sure what you mean by a DateTime control, as DateTime *isn't* a
control - however, there's no concept of a DateTime not being filled
in, any more than there is a concept of an int not being filled in. You
*may* be able to use a special value (eg DateTime.MinValue) as "not
provided" depending on your application.

Alternatively, you could encapsulate the DateTime in a reference type.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #5
JJ
What I meant was there is a datetimepicker control. Sorry for leaving off the
picker part but I figured most people would know that I'm probably talking
about the datetimepicker control.

"mk" wrote:
Incidentally, how would you set the value to null in the first place? I
would recommend that you handle the click or valuechanged event to indicate
user interaction.
BTW: The venerable Mr. Skeet was exactly right in pointing you towards
reference type, not to mention that he similar to the C# forum what
Alexander, Kim, Brian, and Igor are to the ATL forum (sorry
gurus-not-mentioned, I'm very bad on names). Suggesting that a person is
being too technical in a technical forum may be ill-received by some people.
Best regards.

HTH,

mk

"JJ" wrote:
ok the DateTimePicker Control is what i'm using if u want to get technical
about it.
I want to know if someone has not entered a date into it.

JJ

"Jon Skeet [C# MVP]" wrote:
JJ <JJ@discussions.microsoft.com> wrote:
> What's the correct code for checking if a DateTime control is empty
> or not filled in with a date?

Not sure what you mean by a DateTime control, as DateTime *isn't* a
control - however, there's no concept of a DateTime not being filled
in, any more than there is a concept of an int not being filled in. You
*may* be able to use a special value (eg DateTime.MinValue) as "not
provided" depending on your application.

Alternatively, you could encapsulate the DateTime in a reference type.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too

Nov 17 '05 #6
JJ <JJ@discussions.microsoft.com> wrote:
What I meant was there is a datetimepicker control. Sorry for leaving off the
picker part but I figured most people would know that I'm probably talking
about the datetimepicker control.


As far as I can see, a DateTimePicker is filled with the current
date/time until the user chooses something, so there's no concept of
"null" there either.

--
Jon Skeet - <sk***@pobox.com>
http://www.pobox.com/~skeet
If replying to the group, please do not mail me too
Nov 17 '05 #7
On Wed, 11 May 2005 13:59:15 -0700, JJ wrote:
What I meant was there is a datetimepicker control. Sorry for leaving off the
picker part but I figured most people would know that I'm probably talking
about the datetimepicker control.


With the standard DateTimePickerControl a user does not have the
possibility to enter no date. So you always have a valid DateTime value in
the DateTimePickerControl.

If you need a DateTimePickerControl that allows the user to empty the
control, have a look at this solution:
http://www.codeproject.com/cs/miscct...TimePicker.asp

--
Claudio Grazioli
http://www.grazioli.ch
http://www.grazioli.ch/HommingbergerGepardenforelle/
Nov 17 '05 #8

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: 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...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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
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...

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.