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

best way to tell if a date is not assigned?

I want to tell if a date is invaid (not assigned yet)

right now i am doing this

dim aDate as datetime
if aDate.date = #12:00:00 AM#
' not assigned
else
'assigned
end if

which seems to work, but is this the best way to do this?
Mar 14 '06 #1
4 1222
I would compare it with DateTime.MinValue instead of hardcoding what you
have there.

"Brian Henry" <no****@nospam.com> wrote in message
news:ex**************@TK2MSFTNGP14.phx.gbl...
I want to tell if a date is invaid (not assigned yet)

right now i am doing this

dim aDate as datetime
if aDate.date = #12:00:00 AM#
' not assigned
else
'assigned
end if

which seems to work, but is this the best way to do this?

Mar 14 '06 #2
If you are using .NET 1.x, you have to use a magic value as you are doing.
You can use Date.MinValue since it is unlilely that you use it.

If you are using .NET 2.0 you can use the new nullable value types:

Dim dtDate As Nullable(Of Date)

If dtDate.HasValue Then
MessageBox.Show(dtDate.Value.ToString)
Else
MessageBox.Show("No date")
End If

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
"Brian Henry" <no****@nospam.com> escribió en el mensaje
news:ex**************@TK2MSFTNGP14.phx.gbl...
I want to tell if a date is invaid (not assigned yet)

right now i am doing this

dim aDate as datetime
if aDate.date = #12:00:00 AM#
' not assigned
else
'assigned
end if

which seems to work, but is this the best way to do this?

Mar 15 '06 #3
wow didn't know abou the nullable types... definatly going to have to look
into that... now if the controls just were nullable like in a date time
picker and such...
Mar 15 '06 #4
Hi Brian,

Nullable types are new in .NET 2.0 using the new generics (Of T)
capabilities. In .NET 1.x you had to use magic values or implement your own
NullableDate type (there were some implementations out there). For backwards
compatibility the controls may not accept nullable types, but you can extend
them easily with a user control and a new property. The datetime picker has
a ShowCheckbox property or similar.

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio
You can code, design and document much faster:
http://www.mztools.com
"Brian Henry" <no****@nospam.com> escribió en el mensaje
news:O7*************@TK2MSFTNGP10.phx.gbl...
wow didn't know abou the nullable types... definatly going to have to look
into that... now if the controls just were nullable like in a date time
picker and such...

Mar 15 '06 #5

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

Similar topics

136
by: Matt Kruse | last post by:
http://www.JavascriptToolbox.com/bestpractices/ I started writing this up as a guide for some people who were looking for general tips on how to do things the 'right way' with Javascript. Their...
1
by: Terry Olsen | last post by:
Can I bind directly to an .mdb database? Or is using MSDE/SQL better? I am trying to design a web form that presents a list of Projects & Sites, displays the current status of each project at...
6
by: Mike Koerner | last post by:
Hi, I am having problems setting the HttpWebRequest Date header. I understand that it is a restricted header and I do receive the "This header must be modified with the appropriate property." ...
10
by: Mike Logan | last post by:
I am using the "contract first" design methodology. Contract First is design the WSDL first then design the server and client. However I must design my XSD/XML Schema before anything. I am...
7
by: h7qvnk7q001 | last post by:
I'm trying to implement a simple server-side form validation (No Javascript). If the user submits a form with errors, I want to redisplay the same form with the errors highlighted. Once the form...
29
by: gs | last post by:
let say I have to deal with various date format and I am give format string from one of the following dd/mm/yyyy mm/dd/yyyy dd/mmm/yyyy mmm/dd/yyyy dd/mm/yy mm/dd/yy dd/mmm/yy mmm/dd/yy
2
by: josecruz | last post by:
I hope this make sense... When students leave school (dropout, medical reasons, etc), there is a date field that admission use to record this event. For program evaluation, I want to know what...
5
by: bruce24444 | last post by:
I have a database which assigns warranty claims to people with a main screen showing number of files assigned to each person. The number assigned shows day, week, month and year numbers so they can...
4
by: jmarcrum | last post by:
Hi everyone!! I have a continuous form that allows users to select a record and chnage the DATE that the record is assigned to another DATE within the same year. The button is called "Change plan...
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: 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...
0
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,...
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
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...
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
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...
0
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...

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.