Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Entering dates from seperate years 1

Status
Not open for further replies.

arigsby

Programmer
Oct 21, 2003
19
0
0
US
I am trying to keep users from entering dates for one field being after the date in another field. I have it working if the dates are within the same year.

Ex: I enter a date of 12/12/2004 in one field and 01/01/2005 in another. It is recognizing that 12/12 is after 01/01 when it is really not.

How can i keep this from happening?

Thanks in advance.
 
Dim date1 As Date
Dim date2 As Date
date1 = "1/1/94"
date2 = "12/31/93"

If date1 > date2 Then

messagebox.show("YAY!", "dates and stuff", MessageBoxButtons.OK, MessageBoxIcon.Information)
end if


that should work for you. it does the proper calculation. also, in vb.net you have the following methods:

datediff()
datepart()
getdate(), date(), curdate()

post your code if this doesn't help


hayt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top