Possible to store calculated date?

Johnny Drama

In need of beer...
Local time
Today, 10:34
Joined
Dec 12, 2008
Messages
211
I have a table that contains several dates, two of which are an opened and closed date. I currently use datediff to calculate the number of days between those two dates and display that number on a report, but because it's a calculation instead of data in a table I can't sort/search by number of days. Is it possible to have the calculation be stored in a table?

Thanks in advance!
 
Access 2010 introduced a calculated field, but I haven't used it. What you describe is fairly easy without. You can have create your calculated field in a query:

DaysDiff: DateDiff(...)

which allows you to either search on it:

WHERE DateDiff(...) Between 10 And 20

or use that field to sort on in a report. If you really want to store it in other versions:

http://allenbrowne.com/casu-14.html
 
I'm still using 2007, but doing it in a query should work just as well. My next question is if you don't have a field in a table how can you pull it into a query, i.e., if there's no "date" field in the table, how can you create a "date" field in a query?
 
As I demonstrated. In design view in a new field it would look like:

DaysDiff: DateDiff(...)

Within the DateDiff() function you'd refer to the fields that do exist in the table. That creates a new field that exists only in the query named DaysDiff.
 
Just shows how much a of a newb I am...didn't even realize you were giving me an example. Tried what said, works like a charm. Thanks!
 

Users who are viewing this thread

Back
Top Bottom