Set Date variable to Nothing

  • Thread starter Thread starter Andre Beier
  • Start date Start date
A

Andre Beier

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
 
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
 
Andre Beier said:
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=WrappedDate&as_ugroup=microsoft.public.dotnet.languages.vb


--
Armin

How to quote and why:
http://www.plig.net/nnq/nquote.html
http://www.netmeister.org/news/learn2quote.html
 
* "Andre Beier said:
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.
 
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
 
* "Cor Ligthert said:
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top