Help

filterByFormula Date is within the next 30 days

2816 4
cancel
Showing results for 
Search instead for 
Did you mean: 
Adrian_Jacob
4 - Data Explorer
4 - Data Explorer

Hi there,

Hoping someone can help.

Long story short, I am trying to filter the results AirTable brings back to only the future 30 days.

I have got future days working as below:
filterByFormula: ‘Date >= TODAY()’

But how do I change this to be essentially today + 30?

(Im sure its very simple but I cant get anything working).

Cheers,
Adrian

4 Replies 4
Luiggi_Cuozzo
6 - Interface Innovator
6 - Interface Innovator

Hi

Here is a sample that I think it can works for you. I open in three columns for a better understanding but you can work on the final formula later to have all together.

Captura de pantalla 2018-07-24 a la(s) 11.28.38.png

12

23

34

Rgds

Thanks Luiggi,

Is it possible to write that in javascript without the need to create a new column in AirTable?

e.g. this is what i currently have (minus the within 30 days from today logic)

.select({
view: “Grid view”,
sort: [{field: “Date”, direction: “asc”}],
filterByFormula: ‘Date >= TODAY()’
})

Cheers,
Adrian

I suppose will be easy for somebody who know javascript. (not me, have in mind to learn it in a near future).

These are my formulas:

DATEADD(TODAY(),30,‘d’) /* Here you add 30 days to today /
DATETIME_DIFF({Today+30},Date,‘d’) /
Here you subtract previous calculus to your date /
IF(AND({Days Diff}>=0,{Days Diff}<=30),“YES”,“NO”) /
Here you evaluate if it is in range (next 30 days) */

Surely you can put altogether in a formula that should look something like this:

sort: [{field: “Date”, direction: “asc”}],
filterByFormula: ‘AND(DATETIME_DIFF(DATEADD(TODAY(),30,‘d’),Date,‘d’)>=0,DATETIME_DIFF(DATEADD(TODAY(),30,‘d’),Date,‘d’)<=30)’

But you have to try it.

Best luck

Thanks Luiggi

For ref I eventually worked it out to be:
filterByFormula: “IF(Date >= TODAY(), Date <= DATEADD(TODAY(), 30, ‘days’))”

A.