Help

Return value from another table based on today's date

1759 1
cancel
Showing results for 
Search instead for 
Did you mean: 
De_Deus
4 - Data Explorer
4 - Data Explorer

Guys, how are you? I have two tables
table 1
columns
id
date
text

Ex:
1, 12/09/2019, test 1
3, 10/10/2019, test 2
4, 12/11/2019, test 3
5, 12/12/2019, test 4
6, 12/13/2019, test 5

And I have a table 2 with the same fields. However in table 2 the data field is Today () and has only one row.
I need to look in table 1 for today’s date and return the text. How do I do that?

Return test 5 in table 2
1, today (), ‘test 5’

1 Reply 1

Welcome to the community, @De_Deus! :grinning_face_with_big_eyes: If I understand you correctly, you’re trying to isolate the data in the {Text} field from [Table 1] for the record with the date matching today’s date, and have that show up in [Table 2]. Is that correct? If so, this can be done, but you’ll need to do some setup first.

For starters, every record in [Table 1] will need to link to that single record in [Table 2]. If you don’t care what’s in the primary field in that lone [Table 2] record, just add a period. Or you could label it “Current” or “Summary” or whatever makes sense in your situation. I’ll go with “Current” in this case, as it seems to fit what you’re doing based on your description. Also, you don’t actually need a field with TODAY() in it for this to work, so I’ll leave that out. The actual comparison against today’s date will happen in [Table 1], as I’m going to demonstrate.

Screen Shot 2019-12-13 at 8.16.45 PM

Once that’s done, go back to [Table 1] and add a link field pointing to [Table 2]. In the first record, link to that lone [Table 2] record manually, then drag-fill that link into all the other records.

Screen Shot 2019-12-13 at 8.18.20 PM

Here’s where the date comparison will happen, but it’s a little trickier than you might think. First off, here’s the formula that I put into a field named {Today's Text}, which will only output the text for the record where {Date} matches today’s date:

IF(DATETIME_FORMAT(Date, "L") = DATETIME_FORMAT(NOW(), "L"), Text)

EDIT: I originally had a long, convoluted description here of how the TODAY() function behaved, only to discover just now that my understanding was off. Not only that, but TODAY() appears to be returning a different date than NOW(), which is really confusing. I’m reporting this to Airtable support. Thankfully NOW() works just fine, so all is well. :slightly_smiling_face: Once set up, you should get this:

Screen Shot 2019-12-13 at 8.45.54 PM

Now return to [Table 2], where you’ll change the {Text} field to be a rollup bringing in the data from {Today's Text}, using the ARRAYCOMPACT aggregation function to strip out all the blank entries, leaving only the one you want:

Screen Shot 2019-12-13 at 8.49.09 PM

Screen Shot 2019-12-13 at 8.49.58 PM

Repeat the formula field in [Table 1] and the rollup in [Table 2] if you want to do the same with the ID field.

Does that get you what you want?