Trying to substract days from a date


#1

Hello
I want to anticipate date based on certain selection. So when you select an option in the single select field it output a specific number of days in {Style délais} and update a date field
I’m still getting #ERROR! and without a debugging console I can’t see where is the problem

Date de livraison = date field
Style délais = integer formula field (based on a single select field)

DATETIME_PARSE(DATEADD({Date de livraison} - {Style délais}, ‘days’), ‘D MMM YYYY’)


#2

In DATEADD you have separated the 2 parameters with -, you need a comma.


#4

Thank you Elias it’s acting as an operator.
Date de livraison - Style délais
otherwise
21/7/18 - 20 days = 1/7/18


#5

DATEADD needs 3 parameters: https://support.airtable.com/hc/en-us/articles/203255215-Formula-field-reference


#6

Two issues:

  1. As @Elias_Gomez_Sainz notes, DATEADD() requires three parameters. To subtract a certain number of days, you would make the second parameter negative, as so:

    DATEADD({Date de livraison}, -{Style délais}, 'days')

  2. DATEADD() returns a date, while DATETIME_PARSE() expects a string input. If you’re trying to format the date into 'D MMM YYYY' format, use DATETIME_FORMAT() instead.


#7

I was doing this:

Formula:

DATEADD(Date, Days, 'day')

Negative

Formula:

DATEADD(Date, -Days, 'day')


#8

It’s all clearer after a night sleep.
Date parsing was also useless.
Thank You Elias I strip it down to the basics and it works.
DATEADD({Date de livraison},-({Style délais}),‘d’)