Date Expression in Query

Smurfit-Stone

Active Member
Joined
Dec 1, 2004
Messages
485
Hello, I have a dbase with employee info. I have a field called HireDate. Currently a query prompts the user for a month (e.g. 1,2,3, or Jan. Feb or Mar.) and it displays the results ( all the employees hired in that month). I now need an expression that will tell me how many years the employee has worked. It should use the current date and subtract the Hire Date, thus giving me years of service. example say, a person's Hire Date was 11/29/1998 and today is 12/1/2005, I would like to see a result of 7 years of service......Thanks
 

Some videos you may like

Excel Facts

Can a formula spear through sheets?
Use =SUM(January:December!E7) to sum E7 on all of the sheets from January through December

pritcham

Board Regular
Joined
Oct 26, 2005
Messages
128
Hi

Something like the following should do the trick for you:

Years_Of_Service: DateDiff("yyyy",[HireDate],Now())

Where [HireDate] is your field that stores when they started.

Martin
 

Watch MrExcel Video

Forum statistics

Threads
1,122,356
Messages
5,595,681
Members
414,009
Latest member
SNesbyCarr

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Top