DateTime.Compare Functionality in Vb.net

G

Guest

Hello, I'm having a problem I'm hoping that someone can help me out with or
at least explain to me what is going on. My problem involves the
datetime.compare Method. I wrote a app with two datetimepicker controls. This
app is running on 7 XP Pro machines total. Anyway, in my code I have a class
member for both datetimepicker controls that are assigned the values that the
user chooses.

So it's like
Private date1 as DateTime
Private date2 as DateTime

I have a validation section in this class that checks the dates to compare.
Basically, date1 can not be greater than date2 :

if DateTime.Compare(date1, date2) > 0 then
msg += "Date 1 can not be greater than Date 2"

The problem is on 2 of these XP Pro machines I get the message that "Date 1
can not be greater than Date 2" when both dates are the same. During my
testing I've printed out the values of each memeber and they both would be
equal in the date and time e.g. #05/11/2005 8:00AM# Can someone explain what
I'm doing wrong? Thanks.
 
C

Cor Ligthert

Terrance,

This has most probably not to do with VBNet or whatever.

When you use two DateTimePicker you are only able to test those on equality
when they are not yet changed. The give the date in 100-Nanosecond ticks you
know (whatever that is).

Probably what you want to compare is the datetime.date what is the date part
or something like that.

I hope this helps,

Cor
 

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

Top