YEARS OF SERVICE

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there an easy way to have Access calulate an amount of years in service
from a beggining date to current? i.e. The person stared working in 2000 when
the record is searched it updates to reflect the amount of years in service.
I also would like it to automatically update each time the record is queried.

Thanks,

Ray
 
Instead of storing it, just use a query or expression to show it:

YearsOfService = DateDiff("yyyy", [StartDate], Date()) + ((Month(Date()) *
100 + Day(Date())) < (Month([StartDate]) * 100 + Day([StartDate])))
 
You don't store a calculated value like this in the table. When you need to
use this value in a qurey, form, or report, simply insert the formula to
calculate it.

To perform the calculation, use the Datediff function. You will need to see
if the date has passed to get a true number of years. The formula would be
something like:

DateDiff("yyyy",[AnnivDate],Date())+(Format([AnnivDate],"mmdd")>Format(Date(
),"mmdd"))

Rick B
 
What is the difference between the 2 datediff methods use by Ken and Rick?
Both methods gives same results?

Herman
 
Difference is that Rick posted a simpler way of doing the calculation. Ken
did it the "hard way"! Use Rick's!
< g >
 
Back
Top