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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Compare a date field to the system date 1

Status
Not open for further replies.

ddansie

Technical User
Nov 19, 2002
13
0
0
US
I have a "Next Contact" date that I want to compare to the system date to see if it is in the future. If it is I want the query to display that note. Can someone help me out with this please.
 
Hello,

Try something like this:

Dim nextdate As Date, value As Integer

nextdate = "Dec. 12, 2002"
value = DateDiff("d", nextdate, Now)
If Value < 0 then
'do whatever
End if

Let me know if this helps. Regards,
gkprogrammer
 
I'm not sure how many other fields you have in your table and what your table name is, but it would work like this.

Select Note, ContactDate
FROM tblContact
WHERE ContactDate > Date();
 
Thank you for your help....... I need to ask one more question. In my query I have sorted the dates in desending order, but when I bring up my form that was generated from my query it does not display in sorted order... I can't figure out what is it sorting on, all the info is there, but there is no rhyme or reason for how it is being displayed.
 
If you sort first by ContactDate, then base your form on that query then you should be getting records in descending date order.

Select Note, ContactDate
FROM tblContact
WHERE ContactDate > Date()
ORDER BY ContactDate DESC;
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top