Date calculations

mn7

New member
Local time
Yesterday, 22:37
Joined
Feb 8, 2007
Messages
8
Hi

I have a field for 'deadline' date and I need to show all records where the deadline date is within 7 days of todays date. (Obviously todays date will change daily...)

I have tried subtracting the date from todays date but it doesnt work.

All help appreciated, thanks

Martin N.
 
Date()-7 = 2/1/2007
Date()+7 = 2/15/2007

Those both work, so I'm not sure what the problem was there. Regardless, DateDiff will do the trick.

Code:
If DateDiff("d",Date(),Deadline_Date_Field) <=7 Then
    <Your code when it's within seven days>
End If
 
there's a function to use in Queries called DateDiff().


DateDiff («interval», «date1», «date2», «firstweekday», «firstweek»)

for intervals you put the letter corresponding to the format. "d" for days., "w" for weeks. and so forth. (Bust use quotations.)
 
Thanks

Thanks for your help, these work fine.

Martin.
 

Users who are viewing this thread

Back
Top Bottom