# Time period

Hi there!

There is an interesting task: to compare time periods.

Scenario: there are two tables, both of which indicate the validity period of the promo code. The period is expressed as a start and end date. Tables are linked by relations that track changes in rows. The problem is that if the date is stored not as a number, but as a date, then months cannot be compared.

How can you compare dates and show the results to the user with a spread of + or - 2 days?

I only see a solution if the date and the first table is split into separate cells and stored as a number.

What solution do you see?

You should be able to do this using the available date math functions in Glide, but itās not clear to me exactly what your comparison criteria are. Are you just trying to determine if the two time periods overlap? Or something else?

Yes it is

Can you show some sample data, please? (with expected results based on that data).
I just want to be sure that I understand the problem correctly, before I suggest a solution.

For example, the promo code is valid from 2.02.20 to 28.03.20. User set the time range for the promotional code from March to April. As a result, the user should see this promo code plus promotional codes for April.

If the user should see promo codes for April, is the given end date (28 March) even important?
Could I restate that as:

• Given a Start Date, show me any codes that are valid as of that date or any time in the future

??

Sorry, I misreadā¦ let me digest that a bit more and give a better responseā¦

3 Likes

Itās brilliant!
Such a simple and working solution!
Big thanks!

2 Likes

Now I ran into another problem: what to do if the data is on different sheets? I did it through Arrowformula, but then the values are in different cells, that is, they cannot be copied, and the ultimate goal is to copy the desired string into the third table.

The usual way to do this is to create a relation between the two tables, using a column that is common to both. You can then use Lookup columns to bring the values across from one sheet to the other.

If you can provide a screenshot of what each table looks like in the Glide Data Editor, I can probably offer some more specific advice.

Can i add you in team so you can see the tables?

Yes, okay. Iāll PM you my email address.