Skip to main content

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

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.






Rgds


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.






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: r{field: “Date”, direction: “asc”}],

filterByFormula: ‘Date >= TODAY()’

})


Cheers,

Adrian


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: r{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: g{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


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.


Reply