Deleting Row in Airtable if the date is on the past

Hi there,

I’ve been trying to do this:
That’s an tennis app that allows people to create tennis games. Other players can join the game just by clicking an Item list shown in the app retrieving data from Airtable.

I want that, everyday, this table where all the games are, auto-updates and delete the old games, just keeping the new ones.

This is what i tried

The data are shown like this:
Dec 1, 2022 and Nov 30, 2022 (and they must stay like this)

Everything went smooth until today, apparently it doesn’t recognize the fact the the 30th of November is smaller than the 1st December.

Any ideas on how i can fix this?
I can make it using the component “seconds since 1970”, adding this information while creating a game, but i’m sure there’s a faster walkaround.

Thank you very much!

Seconds since 1970 is the most accurate way to do that.

I thought that too, but i’m facing an issue.

A player creates a game when he clicks the button, but the game is set and played further on (might be in the evening or the day after or in two days).

ex.
I do create a game now at 12.42, 1 Dec 2022 (i can get the seconds from 1970 easily), but i want to play tomorrow.
The value that I store is 2 Dec 2022 (how can i get this value’s “1970 seconds”?)

Seems tricky and right now i can’t find a proper solution

EDIT:
i meant, can i extract the “seconds from 1970” component using a date in the future? The component has just the “end” as block.
From the Date_Input component based on a date in the future, how can i extract the seconds?

For now i found a walkaround, accidentally it has deleted all the data on the first time, hopefully it won’t do it again. I’ve been testing and it seems to work good.

Just posting here in case someone in the future will face a similar problem.
I used the first 3 letters of the Data(the date) that symbolize the month (es. “Nov”). If the month is different from the one we are right now, it automatically deletes the rows.
I think it might be a solution even tho i’m not sure about it.

You might consider using Javascript for this:

Thank you for your help but i’ve no clue on how implement this in my app.
Literally lost.

I’m definitely not an expert at Javascript so I might not be the best person to help you but the general idea is to create a script and upload it to your project. Then, you assign the script .html file to the Web Viewer as its url. And finally, you use the Web Viewer message event blocks to send and receive data from the script. I know that’s just an overview… I wish there was a full tutorial on this but I’m not aware of one.

This is a pretty good explanation: GitHub - thunkable/webviewer-extension: Communicate between the Thunkable Web Viewer and a website

And a couple other useful links: How to send/receive a message using js - #2 by jaythemanchs and Date operations (No API) - #3 by muneer

@domhnallohanlon I saw an old tutorial video you posted about this process. It would be great to have an updated version!

2 Likes

Ooh… and @jared has this:

Fun Share: Fun with Date Formatting

2 Likes