473,503 Members | 1,775 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Status of Date Variable

This is for a Win form.

How do I check if the date variable is null?

DateTime dtDOB = (DateTime) dgSportsman[rowNum, 8];

Nov 17 '05 #1
3 1106
if (dtDOB == null)
{
}
"Mike L" <Ca***@nospam.nospam> wrote in message
news:02**********************************@microsof t.com...
This is for a Win form.

How do I check if the date variable is null?

DateTime dtDOB = (DateTime) dgSportsman[rowNum, 8];

Nov 17 '05 #2
If that's from the database you might want.

if(dgSportsman[rowNum], 8 != DBNull.Value)
{

}

"Mel Weaver" <Mel@[remove spam]insdirect.com> wrote in message
news:%2****************@TK2MSFTNGP10.phx.gbl...
if (dtDOB == null)
{
}
"Mike L" <Ca***@nospam.nospam> wrote in message
news:02**********************************@microsof t.com...
This is for a Win form.

How do I check if the date variable is null?

DateTime dtDOB = (DateTime) dgSportsman[rowNum, 8];


Nov 17 '05 #3
Mike L <Ca***@nospam.nospam> wrote:
This is for a Win form.

How do I check if the date variable is null?

DateTime dtDOB = (DateTime) dgSportsman[rowNum, 8];


It can't be. There's no concept of a null DateTime in C# 1.1. (There is
in 2.0 - or rather, there's the concept of a null Nullable<DateTime>.

However, if you want to find out whether a value from a database is
null, that's a different matter - you should be using DbNull. For
instance:

if (dgSportsman[rowNum, 8] is DbNull)
{
...
}

--
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

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

Similar topics

1
2553
by: Ken Elder | last post by:
I need to place the date a MySQL table was last updated into a PHP variable. SHOW TABLE STATUS provides lots of information, including update_time, for all of my tables. But how do I assign the...
1
633
by: Ken Elder | last post by:
I need to place the date a MySQL table was last updated into a PHP variable. SHOW TABLE STATUS provides lots of information, including update_time, for all of my tables. But how do I assign the...
6
2822
by: Nick Horrocks | last post by:
I have set up a custom error page for 404 errors. However the HTTP status code returned is 302 followed by 200, this causes search engines not to remove old pages from their index. How can I...
4
2471
by: Michael C# | last post by:
Given a DateTime variable, what's the best way to check "minor" status (i.e., less than age 18 years) based on today's date? I came up with this: Dim minor As Boolean = true 'dtDOB is a...
0
1341
by: nukiee | last post by:
I wanted to check the status code that comes back as response from the HttpWebResponse. So I used the following code - res = (HttpWebResponse) req.GetResponse(); It's working great, but if I...
0
7076
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
7323
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...
1
6984
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
7453
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
5576
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,...
1
5005
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...
0
4670
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...
0
3162
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3151
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?

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.