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
 

Excel Facts

Best way to learn Power Query?
Read M is for (Data) Monkey book by Ken Puls and Miguel Escobar. It is the complete guide to Power Query.

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
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,164,098
Messages
5,835,368
Members
430,353
Latest member
GS90

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