Problems with "+" operator

Hi all, I seem to have some problem with a simple math function. I want to add some days to today’s date and I use this formula right now:

This gives me the output of 17 (1+7 = 17 in this case).

If I replace my + operator to the - operator, this function gives the right input (-6):


image

So when I first use the - operator, followed by the + operator then it does use + operator in the right way:


Conclusion: I think this is a bug.

PS. I know I can use the function addDays to add a number of days, but my goal is to find the first ‘Friday’ after today’s date, so I need to do some math (possibly mod function) with today’s date first.

Welcome to the Make community!

You can use the built-in function parseNumber

{{ parseNumber(number; decimal separator) }}

e.g.: (paste this into the field)

{{ parseNumber(formatDate(now; "d")) + 7 }}

The reason is twofold:

  1. formatDate returns a string variable

  2. You can use a + symbol to also join two strings, but as soon as a - is used, it tries to evaluate it as a math operation. This is normal behaviour in JavaScript, and is not a Make bug.

For more information, the function’s documentation can be found in the Help Centre. You should also complete the tutorials in the Make Academy.

Hope this helps! Let me know if there are any further questions or issues.

@samliew

P.S.: Investing some effort into the Make Academy will save you lots of time and frustration using Make.

4 Likes

Thanks @samliew. I didn’t know about the + operator that it could join characters together as well. Solved indeed. Thanks

2 Likes