API: returns value bigger than

Hi all,
I have this API request: http://192.168.0.29:8484/api/docs/nwpM2foEYTWHHVAhraddAo/tables/Programma_tecnici/records?filter={"Giorno": [1713679200]} that works, but I need to retrieve all the records that has the column Giorno bigger than a value, not equal to.
How do I do that?
Thanks!

I think you will need to create a formula column in your table (e.g., Giorno Filter: $Giorno > 1713679200), then you can call the API with the filter ?filter={"Giorno Filter": true}

That’s a nice solution.
What could the formula be to get the result true if Giorno is bigger than 2 days ago?

Try this:
Giorno Filter: $Giorno > DATE_ADD(TODAY(), days=-2)

I think I’m missing something because the formula doesn’t give me any error, but the column is empty:
18-04-2024_18-42-19_0_Produzione_-Grist—_Mozilla_Firefox

Hi @Andrea3.

It looks like you’re using a trigger formula in your screenshot. They aren’t like regular formulas; they only get evaluated in certain situations, like when a new record is created, or when specific fields are modified.

Try changing it to a regular formula by clicking the dropdown labeled “Data Column”, then “Clear and make into formula”.

Also, I think it should be DATEADD instead of DATE_ADD in the formula.

George

Hi @georgegevoian
I did that, but I get error (also with DATEADD).
18-04-2024_19-14-49_3_Produzione_-Grist—_Mozilla_Firefox

What does the error say when you open the formula editor?

George

TypeError : can't compare datetime.datetime to datetime.date

I’ve tried using NOW $Giorno > DATEADD(NOW(), days=-2) , but I get the same error

I’m guessing the $Giorno column type is “DateTime” then. If you need the time for that column (not just the date), use this formula for Giorno Filter: $Giorno.date() > DATEADD(NOW(), days=-2)

If you don’t need the time and just want the date in the $Giorno column, change that column type from “DateTime” to “Date”, and your previous formula should work: $Giorno > DATEADD(NOW(), days=-2)

2 Likes

Thanks a lot, that worked!!!

1 Like