ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Date since hired displayed in years.months (https://www.excelbanter.com/excel-programming/361666-date-since-hired-displayed-years-months.html)

JL[_4_]

Date since hired displayed in years.months
 
Hi,
I have a spreadsheet that calculated the time a person has been working for
the company. However in some cases I have not been given the date hired so
my results are incorrect.

I am using the formula

=DATEDIF(D27,TODAY(),"Y") & "." & DATEDIF(D27,TODAY(),"YM")

Where D27 refers to the date in the previous column. If the date column is
empty the result is something like 106.4 meaning 106 years and 4 months.

The formula works great in all other circumstances giving results such as
7.3 for seven years three months.

Is there a way to check to see if the date field is empty first, then make
the result field remain empty, and then still work on the other fields?

Can anyone modify the above code to check first for an empty field?

Thanks

JL



JMB

Date since hired displayed in years.months
 
wrap your formula with the IF function.
=IF(D27="","",DATEDIF(.......))


"JL" wrote:

Hi,
I have a spreadsheet that calculated the time a person has been working for
the company. However in some cases I have not been given the date hired so
my results are incorrect.

I am using the formula

=DATEDIF(D27,TODAY(),"Y") & "." & DATEDIF(D27,TODAY(),"YM")

Where D27 refers to the date in the previous column. If the date column is
empty the result is something like 106.4 meaning 106 years and 4 months.

The formula works great in all other circumstances giving results such as
7.3 for seven years three months.

Is there a way to check to see if the date field is empty first, then make
the result field remain empty, and then still work on the other fields?

Can anyone modify the above code to check first for an empty field?

Thanks

JL





All times are GMT +1. The time now is 04:29 PM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com