0

I am trying to develop a formula to determinate current days until the end of a campaign.

For that i have the following fields

  • Start Date
  • End Date
  • Days from Today to End Date

The code that i am implementing and its not working correctly is.

IF( Now()  >= EndDate , 0, EndDate -  TODAY())

So basically what i want to accomplish is. If today is equal to the end day of the campaign return 0 else return the remaining days.

5
  • You say it's not working correctly, but what exactly is it doing now? Commented Jan 23, 2015 at 9:16
  • keeping this number value EndDate - TODAY() Commented Jan 23, 2015 at 9:21
  • Do you mean it always shows the result of EndDate - TODAY()? Commented Jan 23, 2015 at 9:22
  • I think i kinda know the mistake. It gives false because its false :D What i want to accomplish is if Now is equal or bigger than End Date... I tried that at this moment but it gives error Error: Incorrect parameter type for operator '>'. Expected DateTime, received Date Commented Jan 23, 2015 at 9:23
  • I thought so too, please try the answer I added. :-) Commented Jan 23, 2015 at 9:25

2 Answers 2

3

Firstly, you should use TODAY() instead of NOW(). NOW() returns a datetime while TODAY() returns a date. This means you can't compare NOW() to EndDate.

Another problem is that it only shows 0 if the EndDate is exactly equal to TODAY(). This is only one day. You want to check whether EndDate is greater than TODAY():

IF( TODAY() > EndDate, 0, EndDate - TODAY() )

3
  • I still get this error: Error: Incorrect number of parameters for function 'DATE()'. Expected 3, received 0 Commented Jan 23, 2015 at 9:28
  • Woops, please try my changed answer :-) Commented Jan 23, 2015 at 9:29
  • Works like a charm. I rushed with my question It wasn't that hard at the end. Thanks @Koen Commented Jan 23, 2015 at 9:31
1

What you want is DATE() formula. Because NOW() returns a DateTime value. Comparing a DateTime with a Date will always return false. Try using DATE(NOW())

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .