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

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

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,530
Messages
5,596,699
Members
414,088
Latest member
rodriboraun

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