Help

Formula with DATETIME_DIFF(NOW()

Topic Labels: Formulas
1001 2
cancel
Showing results for 
Search instead for 
Did you mean: 
superfabio
4 - Data Explorer
4 - Data Explorer

Hello, I have this formula, but the result is always in hours. Where is the error?

Thanks
Fabio

 

 

IF(
  Stato = "Campagna",
  IF(
    DATETIME_DIFF(NOW(), Chiusura, 'hours') > 48,
    DATETIME_DIFF(NOW(), Chiusura, 'days') & " giorni",
    IF(
      DATETIME_DIFF(NOW(), Chiusura, 'hours') < 48,
      DATETIME_DIFF(NOW(), Chiusura, 'hours') & " ore",
      IF(
      DATETIME_DIFF(NOW(), Chiusura, 'hours') < 8,
      DATETIME_DIFF(NOW(), Chiusura, 'minutes') & " minuti"
    )
  )
)
)

 

 

2 Replies 2

Hmmm. I think you might have one too many IF statements. I’m on mobile so I’m going to paraphrase your formula:

If DATETIME_DIFF>48 hours, days, if DATETIME_DIFF>8 hours, hours, minutes.

Also, your username is fantastic!

superfabio
4 - Data Explorer
4 - Data Explorer

Thank you for your reply! In the meantime, I have found the solution (thanks ziotitanok!). The problem was that, due to how I wrote the formula, I was getting a negative result, and as a consequence, the various IF statements couldn't work. Now, I have reversed DATETIME_DIFF(NOW(), Chiusura) to DATETIME_DIFF({Chiusura}, NOW()), and the formula works. I could have inverted the operators and used a negative number, but I prefer having a positive result.