DateDiff("m", "06/14/1982", "09,01,1982") = 3
A1 = 06/14/1982
A2 = 09/01/1982
=DATEDIF(A1, A2, "m") = 2
如果我需要DateDiff
像<{1}}那样围绕向下,我该如何做到这一点?
答案 0 :(得分:3)
您可以在VBA中使用Evaluate
功能。但是,以这种方式处理日期时,需要确保公式所看到的值是与日期对应的数字,而不是VBA日期数据类型。如果日期存储在工作表单元格中,您可以执行以下操作:
Evaluate("DATEDIF(" & [a1].Value2 & "," & [a2].Value2 & ", ""m"")")
如果日期在VBA变量中存储为日期,则:
Evaluate("DATEDIF(" & CDbl(DT1) & "," & CDbl(DT2) & ", ""m"")")
答案 1 :(得分:1)
if (startIndex == endIndex) {
if (numbers[endIndex] <= firstNumber)
return numbers[startIndex];
}