In addition to the other comments.
You are comparing 2 date & time values.
It sounds like you want to compare 2 date values.
Remove the Time values from the dates & compare away.
| If AddTo.Date <= AddFrom.Date Then
If you have 2 date time values, and want just the Time you can use
DateTime.TimeOfDay property.
' VS 2005 syntax
| If AddTo.TimeOfDay <= AddFrom.TimeOfDayThen
--
Hope this helps
Jay B. Harlow [MVP - Outlook]
..NET Application Architect, Enthusiast, & Evangelist
T.S. Bradley -
http://www.tsbradley.net
<Br*******@gmail.com> wrote in message
news:11**********************@i40g2000cwc.googlegr oups.com...
| I'm having a problem with VB 2005. I'm trying to compare 2 dates as
| follows:
|
| If AddTo <= AddFrom Then
| 'Error Code
| Else
| 'Happy Code
| End If
|
| AddFrom should be earlier than AddTo.
|
| This works great unless the AddTo has a time in the 12:00 AM hour and
| AddFrom has the same day as AddTo but a later time.
|
| Example:
|
| 6/26/2006 12:00:01 AM 6/26/2006 11:45:00 PM - True
| 6/26/2006 12:00:01 AM 6/27/2006 11:45:00 PM - False
| 6/26/2006 1:00:00 AM 6/26/2006 11:45:00 PM - False
| 6/26/2006 1:00:00 AM 6/25/2006 11:45:00 PM - True
|
| Is this a flaw in VB or in my logic?
|