Using the difference between dates in an IF statement

MarkCep
MarkCep ✭✭✭✭✭
edited 02/26/25 in Formulas and Functions

I have a column the calculates the number of days between 2 dates, which is fine.

=[Arch Prelims]@row - [FP Arch Engagement ]@row (gives me a number)

But I don't want to do the calculation if the difference is a negative number. There are few instances where the result would be a negative number (very few) I don't want to include values for negative numbers. I tried using an IF statement results in a #UNPARSEABLE error.

=IF([Arch Prelims]@row -[FP Arch Engagement]@row > 0, [Arch Prelims]@row - [FP Arch Engagement]@row, 0)

both of the fields are Dates.

Help!

Tags:

Best Answers

  • Protonsponge
    Protonsponge Community Champion
    edited 02/26/25 Answer ✓

    Hello @MarkCep,

    You could have a formula that said if [Arch Prelims]@row - [FP Arch Engagement ]@row is less than zero, show blank else, [Arch Prelims]@row - [FP Arch Engagement ]@row. I think that would give you what you are looking for.

    =IF([Arch Prelims]@row - [FP Arch Engagement]@row < 0, "", [Arch Prelims]@row - [FP Arch Engagement]@row)

    I hope that is helpful to you in some way,

    Protonsponge

  • Nick Korna
    Nick Korna Community Champion
    Answer ✓

    @MarkCep, the second formula should work (having tested it) - is it down to the FP Arch Engagement in the first (working) formula having a space at the end of the column and the second formula not?

Answers

  • Protonsponge
    Protonsponge Community Champion
    edited 02/26/25 Answer ✓

    Hello @MarkCep,

    You could have a formula that said if [Arch Prelims]@row - [FP Arch Engagement ]@row is less than zero, show blank else, [Arch Prelims]@row - [FP Arch Engagement ]@row. I think that would give you what you are looking for.

    =IF([Arch Prelims]@row - [FP Arch Engagement]@row < 0, "", [Arch Prelims]@row - [FP Arch Engagement]@row)

    I hope that is helpful to you in some way,

    Protonsponge

  • Nick Korna
    Nick Korna Community Champion
    Answer ✓

    @MarkCep, the second formula should work (having tested it) - is it down to the FP Arch Engagement in the first (working) formula having a space at the end of the column and the second formula not?

  • MarkCep
    MarkCep ✭✭✭✭✭

    Thank you, both answers helped solve the issue.

Help Article Resources

Want to practice working with formulas directly in Smartsheet?

Check out the Formula Handbook template!