calculating age in a query

  • Thread starter Thread starter Buell
  • Start date Start date
B

Buell

Hello All,

Is it possible to calculate age in a access query?
I have a column, initdate, that holds the date the row was written. I also
have an age column that I populate once that row closes.
What I am having trouble with is how to calculate age on a open row. I'm
trying to do a grouping query and group by how old the
open row is. I've tried datediff in my query but it didn't like it.
Also, can you GROUP by a field that is a calculated value in your select
and not a real db field?

TIA,

B*
 
Hello All,

Is it possible to calculate age in a access query?

Age in... what? Days? Years?
I have a column, initdate, that holds the date the row was written. I also
have an age column that I populate once that row closes.

The Age column should ideally not be stored in your table at all. If
it's age in days, then if you store it today, *it will be wrong
tomorrow*. Calculate it on the fly instead.
What I am having trouble with is how to calculate age on a open row. I'm
trying to do a grouping query and group by how old the
open row is. I've tried datediff in my query but it didn't like it.

Age: DateDiff("d", [initdate], Date())

will contain the number of days between initdate and the date that the
query is run (whenever that might be).
Also, can you GROUP by a field that is a calculated value in your select
and not a real db field?

Yes. You can do anything with it that you can do with a real field,
with the exception of editing it.
 
Back
Top