By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,808 Members | 1,481 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,808 IT Pros & Developers. It's quick & easy.

Calculating Dates

P: 1
How do you count 7 days back from a date? Like, give me all transactions that occurred 7 days from today in access.

Thanks for the help.
Oct 24 '06 #1
Share this Question
Share on Google+
4 Replies


Andrew Thackray
P: 76
How do you count 7 days back from a date? Like, give me all transactions that occurred 7 days from today in access.

Thanks for the help.
The function is Dateadd. the syntax is Dateadd(PeriodType,period,date)

in your case it would be

Newdate = Dateadd("d",-7,OldDate)
Oct 24 '06 #2

Expert 5K+
P: 8,434
The function is Dateadd. ...in your case it would be Newdate = Dateadd("d",-7,OldDate)
Also, you can probably use the Now() function for the current time. That would make something like
Expand|Select|Wrap|Line Numbers
  1. Newdate = DateAdd("d",-7,Now())
(You might not need the parentheses after Now - I forget).
Oct 24 '06 #3

MMcCarthy
Expert Mod 10K+
P: 14,534
How do you count 7 days back from a date? Like, give me all transactions that occurred 7 days from today in access.

Thanks for the help.
SELECT * FROM TableName
WHERE [Date Field] BETWEEN Date() And Date()-7;
Oct 25 '06 #4

NeoPa
Expert Mod 15k+
P: 31,489
As the Date in Access is stored as 'Number of Days since ...' and the time is stored as a fractional part of a day, adding/subtracting a number to a date field is equivalent to using
Expand|Select|Wrap|Line Numbers
  1. DateAdd("d",number,[Date Field])
The documentation for DateAdd() also includes an option for adjusting by a weekday ("w"). I've found this not to work (albeit only tested up to Access 2K).
Oct 25 '06 #5

Post your reply

Sign in to post your reply or Sign up for a free account.