Comparison of dates
-
-
VB.NET doesn't use any particular date format. The default dateformat is determined by the system, not VB.NET. You should be comparing two Date objects, not two Strings of text representing the dates. Convert your data from the database, as well as the compare date, to Date objects and use the
.CompareTo()
method of one of them to compare it to the other.Dim dt1 As New Date(2005, 2, 12)
Dim dt2 As New Date(2005, 3, 21)
Dim result As Integer = dt1.CompareTo(dt2)RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
VB.NET doesn't use any particular date format. The default dateformat is determined by the system, not VB.NET. You should be comparing two Date objects, not two Strings of text representing the dates. Convert your data from the database, as well as the compare date, to Date objects and use the
.CompareTo()
method of one of them to compare it to the other.Dim dt1 As New Date(2005, 2, 12)
Dim dt2 As New Date(2005, 3, 21)
Dim result As Integer = dt1.CompareTo(dt2)RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
ya Mr. Dave.. the system date that we tried to enter into the Oracle database through "Today.date.date" is not being entered into the database,,.. wat can be the prob... and so how shud we enter the system date in the database ??
-
ya Mr. Dave.. the system date that we tried to enter into the Oracle database through "Today.date.date" is not being entered into the database,,.. wat can be the prob... and so how shud we enter the system date in the database ??
Without seeing your code, it's impossible to tell you what your doing wrong. RageInTheMachine9532 "...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-
I run into this all the time in my CIS349 and CIS 405 classes. In fact I just emailed a student of mine about a similar problem. use the oracle to_date or to_char functions. in SQL: select * from orders where orderdate between to_date('01/23/2005', 'MM/DD/YYYY') AND to_date('02/23/2005', 'MM/DD/YYYY') for the reverse.... select to_char(orderdate, 'MM/DD/YYYY') from orders; In the latter version when you get your data back from the db into your data container you will already have it in the right format. http://www.jasncab.com/huberblog :: Jason Huber