Work with Date

  • Thread starter Thread starter Bruno
  • Start date Start date
B

Bruno

How do I check if a date variable is empty?

I mean, if I declare a variable like this

dim d as Date

how do I know if any date was assigned to d?

example,
d = now

I am currently using

if d.tostring = "01/01/0001 12:00:00 AM" then
'its empty
end if

but if the UICulture is different from en-US, it won't work....

is there any good way to check this?

Thanks,
Bruno
 
Hi Bruno
What is set in a data object first when it is initialized is a value called
"the minimum value "which is "01/01/0001 12:00:00 AM" for en. There is
always a property with the data object (read only property ) that can
return this minimum value .
What you can do and work with every culture is to compare the value with
in your date object to its minimum value (using the compareto function) if
the returned value is 0 then the date object is still on its initial value.
And this will work with whatever culture.
Basically you would have something like this
Dim k As Date
If (k.CompareTo(k.MinValue) = 0) Then ' means date still on its
intital value
MessageBox.Show(" the date is not set")

End If
Hope that is ok solution with you .
Mohamed M .Mahfouz
Developer Support Engineer
ITWorx on behalf of Microsoft EMEA GTSC
 

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