djc,
Use DateTime.Date to get just the date part of a DateTime value.
Dim date1 As DateTime = #12/15/2004 12:31:23 AM#
Dim date2 As DateTime = #12/15/2004#
Debug.WriteLine(date1 = date2, "date1 = date2")
Debug.WriteLine(date1.Date = date2, "date1.Date = date2")
You can use DateTime.TimeOfDay to get just the time part of a DateTime
value.
Dim time1 As TimeSpan = #12:31:23 AM#.TimeOfDay
Debug.WriteLine(date1.TimeOfDay.Equals(time1), "date1 = time1")
Unfortunately the equal "=" operator is not overloaded to compare TimeSpan
values, we need to wait for VS.NET 2005 (aka Whidbey, due out later in 2005)
to allow overloading the equal operator.
' VS.NET 2005 syntax
Debug.WriteLine(date1.TimeOfDay = time1, "date1 = time1")
WARNING: Time values includes fractions of milliseconds, so be careful when
comparing them for equality (less or greater usually works better).
Hope this helps
Jay
"djc" <no***@nowhere.com> wrote in message
news:uC**************@tk2msftngp13.phx.gbl...
I am confused with all the options for date values... What should I be
using
when I want to compare (=, >, <) two dates, not including the time.. for
example when inserting data in a database the data may have the full date
and time like '12/15/2004 12:31:23 AM'. How do I convert that into just
'12/15/2004'? In other words I need to test if the current date is before
or
after a stored date value, but the time does not matter.
any input is appreciated.