Solved

MS Access 2010 Date help

Posted on 2014-12-08
2
194 Views
Last Modified: 2014-12-08
Hi
Need help with the following please.
We have a query that contains a date field. What we cant to do is add 7 days to this date and then show the last 30 days from today.
So for example I have the following

Date in Table           Add 7 Days      
01/09/2014              08/09/2014
01/12/2014              08/12/2014
02/12/2014             09/12/2014

I can get the query to add 7 days and show the correct date, but I also then want the query to only show me records that have a date from today 30 days back based on the new date I have created, so from the example above the would only return 2 records that have a date in December.  I cant seem to do that as I can seem to add a query to the field that creates the new date, If I try and then run the query I get the "enter parameter value"

Thanks
0
Comment
Question by:George_Milton
2 Comments
 
LVL 84

Accepted Solution

by:
Scott McDaniel (Microsoft Access MVP - EE MVE ) earned 500 total points
ID: 40486494
It would help if you'd show the SQL of your query.

Adding 7 days is straight forward:

SELECT Field1, DateAdd("d", 7, YourDateField) AS NewDate FROM SomeTable

This would create a column named NewDate in the query, and would add 7 days to a field named YourDateField.

If you then want to query and filter on YourDateField for values starting at 30 days in the past:

SELECT YourDateField, DateAdd("d", 7, YourDateField) AS NewDate FROM SomeTable WHERE YourDateField >= DateAdd("d" , -30, Now)
0
 

Author Closing Comment

by:George_Milton
ID: 40486502
Thank you that worked exactly as I expected
0

Featured Post

Free Gift Card with Acronis Backup Purchase!

Backup any data in any location: local and remote systems, physical and virtual servers, private and public clouds, Macs and PCs, tablets and mobile devices, & more! For limited time only, buy any Acronis backup products and get a FREE Amazon/Best Buy gift card worth up to $200!

Join & Write a Comment

Most if not all databases provide tools to filter data; even simple mail-merge programs might offer basic filtering capabilities. This is so important that, although Access has many built-in features to help the user in this task, developers often n…
It took me quite some time to sort out all the different properties of combo and list boxes available from Visual Basic at run-time. Not that the documentation is lacking: the help pages are quite thorough and well written. The problem was rather wh…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now