445,841 Members | 1,704 Online
Need help? Post your question and get tips & solutions from a community of 445,841 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
4 Replies

 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 Newdate = DateAdd("d",-7,Now()) (You might not need the parentheses after Now - I forget). Oct 24 '06 #3

 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

 Expert Mod 15k+ P: 31,660 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 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