473,385 Members | 1,757 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.

Set Date variable to Nothing

Hi,

I have a date variable that initially contains any date. However, depending
on user actions I want to set the value of the date var to Nothing.

I tried the following:

myDate = Nothing --- deletes the date but I always have 12:00:00 AM in
there
myDate = "" --- compiler error
myDate = 0 ---- compiler error

Thanks in advance

Andre
Nov 20 '05 #1
5 6711
On Fri, 23 Apr 2004 11:01:13 -0500, Andre Beier wrote:
Hi,

I have a date variable that initially contains any date. However, depending
on user actions I want to set the value of the date var to Nothing.

I tried the following:

myDate = Nothing --- deletes the date but I always have 12:00:00 AM in
there
myDate = "" --- compiler error
myDate = 0 ---- compiler error

Thanks in advance

Andre


Try something like:

myDate = DateTime.MinValue

--
Chris

To send me an E-mail, remove the underscores and lunchmeat from my E-Mail
address.
Nov 20 '05 #2
* "Andre Beier" <An*********@gmx.net> scripsit:
I have a date variable that initially contains any date. However, depending
on user actions I want to set the value of the date var to Nothing.

I tried the following:

myDate = Nothing --- deletes the date but I always have 12:00:00 AM in
there
myDate = "" --- compiler error
myDate = 0 ---- compiler error


You cannot, because 'DateTime' is a value type and value types are not
"nullable". You may want to use the 'SqlDateTime' datatype, writte a
wrapper class around 'DateTime' which has, for example, an 'IsNothing'
property, or wait for .NET 2.0 which allows nullable value types by use
of generics.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #3
Hi Andre

What is the sense of it, when you want to display a datetime you need almost
forever to use a string format for it.

Cor
Nov 20 '05 #4
"Andre Beier" <An*********@gmx.net> schrieb
Hi,

I have a date variable that initially contains any date. However,
depending on user actions I want to set the value of the date var to
Nothing.

I tried the following:

myDate = Nothing --- deletes the date but I always have 12:00:00 AM
in there
myDate = "" --- compiler error
myDate = 0 ---- compiler error

http://groups.google.com/groups?as_q...t.languages.vb
--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html

Nov 20 '05 #5
* "Cor Ligthert" <no**********@planet.nl> scripsit:
What is the sense of it, when you want to display a datetime you need almost
forever to use a string format for it.


Mhm... The 'ToString' method could return "" for null dates.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #6

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

Similar topics

3
by: Jay | last post by:
I previously posted this question under Visual Basic newsgroup, but was advised to re-post here. I'm hoping someone can help me solve an issue I'm having with VB.Net and Access 2000. Here's...
2
by: Keith | last post by:
Good Afternoon, New to .Net. I am trying to pass date/time values to a MS Access query depending on what value is selected from a dropdown list box (January, February, etc). I have declared...
4
by: wapsiii | last post by:
I'm unsure how best to handle dates from my webforms to my database. Often I have a textbox and a datepicker on a webform. Upon postback dates are received in string format (like DD-MM-YYYY)....
18
by: dfetrow410 | last post by:
Anyone have some code that will do this? Dave
2
by: Oenone | last post by:
In our applications, we use the special value of DateTime.MinValue to represent "null dates" throughout all our code. We recently ran into an issue where we wanted an optional date parameter for a...
9
by: ineedahelp | last post by:
Can anyone help me? I am getting a syntax error on my strSQL statement. I think it doesn't like the way I am trying use my variable mNewDate. The user originally types the date as a string...
21
by: Darin | last post by:
I have an applicatoin that works 100% perfect when running on a machine setup for English (United States), but when I change it to Spanish (Mexico), the dates start giving me fits. THe reason is...
5
by: bps4484 | last post by:
I'm trying to do some date queries on a table, and I want to know if there is some builtin variable within the date datatype which can represent that a day, month, or year could be any value. ...
0
by: =?Utf-8?B?QnJ5YW4=?= | last post by:
Hello group. I've migrated from Win 2003 server to Win 2008 server. I've been banging my head agaist a wall for several days now trying to figure this out. I have the following script that will...
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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...

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.