Skip to main content
Solved

Date calculation formula that ignores blanks

  • November 25, 2021
  • 7 replies
  • 50 views

I have a date formula to work out the number of days between 2 dates, if either or both of the dates are blank, it returns NaN, how can I amend the formula to only perform the calculation if both fields are populated?

(Long overdue a lay-in and my brain is not functioning by itself, need help… :slightly_smiling_face: )

DATETIME_DIFF({Finished},{Started},“days”)

Best answer by ScottWorld

Still getting the same error message


I would use this formula:

IF(
AND(Finished,Started),
DATETIME_DIFF(Finished,Started,"days")
)

7 replies

Dimitris_Goudis
Forum|alt.badge.img+20

Hey @Karen_Gardner,

You can use the following condition:

IF(AND(LEN{Finished}!=0,LEN({Started}!=0)),DATETIME_DIFF({Finished},{Started},“days”,0)

The condition checks if both of the given dates are not blank. If the condition is true then it returns your time difference.

Please check it and let us know if it worked :slightly_smiling_face:

Yours sincerely,
Dimitris Goudis


  • Author
  • Participating Frequently
  • November 25, 2021

Hey @Karen_Gardner,

You can use the following condition:

IF(AND(LEN{Finished}!=0,LEN({Started}!=0)),DATETIME_DIFF({Finished},{Started},“days”,0)

The condition checks if both of the given dates are not blank. If the condition is true then it returns your time difference.

Please check it and let us know if it worked :slightly_smiling_face:

Yours sincerely,
Dimitris Goudis



Getting this error message when copying / pasting the formula.


Dimitris_Goudis
Forum|alt.badge.img+20

Hey @Karen_Gardner,

You can use the following condition:

IF(AND(LEN{Finished}!=0,LEN({Started}!=0)),DATETIME_DIFF({Finished},{Started},“days”,0)

The condition checks if both of the given dates are not blank. If the condition is true then it returns your time difference.

Please check it and let us know if it worked :slightly_smiling_face:

Yours sincerely,
Dimitris Goudis


Sorry I missed some parenthesis :stuck_out_tongue:

Please text me if you have any issue again !


  • Author
  • Participating Frequently
  • November 25, 2021

Sorry I missed some parenthesis :stuck_out_tongue:

Please text me if you have any issue again !


Still getting the same error message


Dimitris_Goudis
Forum|alt.badge.img+20

Still getting the same error message


Hey @Karen_Gardner,

Could you import the function manually in the filed without using copy and paste?

Thanks


ScottWorld
Forum|alt.badge.img+35
  • Genius
  • Answer
  • November 25, 2021

Still getting the same error message


I would use this formula:

IF(
AND(Finished,Started),
DATETIME_DIFF(Finished,Started,"days")
)

  • Author
  • Participating Frequently
  • November 25, 2021

I would use this formula:

IF(
AND(Finished,Started),
DATETIME_DIFF(Finished,Started,"days")
)

Perfect, thank you. Worked