简体   繁体   English

按月划分的Excel任期公式

[英]Excel Formula for Tenure by Month

I have a table set up with Employee Start Date, Termination Dates and then monthly columns - see image below. 我有一个表,其中设置了“雇员开始日期”,“终止日期”,然后是“每月”列-参见下图。

I am trying to calculate the Employee Tenure but based on the following scenarios: 我正在尝试计算员工任期,但是基于以下情况:

  1. An employee has started within the month or is currently employed and has no termination date - Tenure will calculate as normal with Start Date and reporting month (columns CF, CG etc) 雇员在当月内开始工作或目前正在工作并且没有终止日期-任期将正常计算开始日期和报告月份(列CF,CG等)

  2. An employee has terminated - Tenure will calculate with Start Date and reporting month until Termination month and then swap to calculation between start and termination date (columns E, F). 员工已终止-任期将使用开始日期和报告月份进行计算,直到终止月份为止,然后在开始日期和终止日期之间交换到计算(列E,F)。 Once the termination month has passed the tenure will be 0 for that employee. 一旦离职月份过去,该雇员的任期将为0。 eg. 例如。 Start 11-Jan-16, Termination 8-Jul-16, Column CF (June) & CG (July) will calculate as normal and Column CH (Aug) should be 0. 从16年1月11日开始,终止于16年7月8日,CF列(6月)和CG列(7月)将正常计算,CH列(8月)应为0。

Here is an image of my current worksheet set up: 这是我当前工作表设置的图像: 在此处输入图片说明

The formula I have currently is: 我目前拥有的公式是:

=IF(OR(CF$2>CurrentReportMonth,$E9>CF$2),0,IF($F9>CF$2,0,IF(OR($E9<=CF$2,$F9<CF$2),DATEDIF($E9,CF$2,"M"),DATEDIF($E9,$F9,"m"))))

Here is the summary of our discussion: 这是我们讨论的摘要:

=IF(OR(CF$2>ReportDate,AND($F9>0,$F9<CF$2),$E9>=CF$2),"-",IF(AND($E9<=CF$2,$F9=0‌​),DATEDIF($E9,CF$2,"M"),IF(AND($E9<=CF$2,$F9>CF$2),DATEDIF($E9,CF$2,"M"),DATED‌​I‌​F($E9,$F9,"M"))))

Use this formula at cell CF9 and copy up and down, and that should get the result. cell CF9使用此公式,然后向上和向下复制,这样可以得到结果。

Try this: 尝试这个:

=IF($A25>$F$24,0,IF(AND(LEFT(CELL("format",$B25),1)="D",$B25<$F$24),0,IF(ISNUMBER(F25),F25+1,1)))

NOTE : 注意
My data setup in the file: 我在文件中的数据设置:

  • Column A = Start Date A栏= Start Date
  • Column B = Termination Date B栏= Termination Date
  • I had my monthly dates starting from column E 我的月度日期从E列开始

You will have to adjust the column names as per your worksheet but this should give you the results you want 您将必须根据工作表调整列名,但这应为您提供所需的结果

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM