comparing two dates.

stuartkeith

Registered User.
Local time
Today, 06:34
Joined
Jan 5, 2007
Messages
15
Thanks for the help on my last question. One more small one.

How do I compare two dates to check if the entered date is newer or older than the current date. I have tried
Code:
 if date > thendate then xxx
but that dosent work correctly.

What I am doing is comparing the expirey date of a warranty and if it has passed then a note is given saying that the warranty has now expired.

thanks
 
That should work do you have your variables defined as Date or String?
 
thendate as date. At present it dosent matter if the date has expired or not it still executes the expired date option
Code:
Private Sub changelabels()

If Date > thendate Then
    expirelable.Caption = "Warranty Expired"
    expirelable.ForeColor = 255
End If

If Date < thendate Then
    expirelable.Caption = "Expires"
    expirelable.ForeColor = 10040115
End If

End Sub
 
IT seems as thendate is not reciving the date. I am using

Code:
thendate = me.expire.text

when I use the message box function to display thendate, it appears blank!
 
Last edited:
KeithG said:
can you post an example db?

Sorry no , as it is classed as "Secret" basicly

user enters purchase date of unit as date "dd/mm/yyyy" into a text box (txt_purchase)

user chooses from a drop down box how many years wrnt it comes with. (com_years)

This then populates a text box with the date the wrnt will expire. (txt_expire)
and sets the varible "thendate" as the date it will expire.

Now what happens is when the user looks at the record it checks the date stored in "thendate" with the current date. (date)

If the date has expired it then changes a label from "expires on" to "Warranty Expired"

I have used "thendate" as when I tried to use txt_expire.text I got a "object cannot be refrenced unless it has got focus" errors.
 
date.jpg
 

Users who are viewing this thread

Back
Top Bottom