Comparing Date Input value to an end date

I need your help, I don’t know if it can be done, but I hope it!!
I have a first screen like in this photo:

With, for example, three objects.

I click on the subject “N” and I go in the second screen like this photo:

As you can see, there is a first “PrimoN” label with its calendar, the second “SecondoN” label with its calendar, etc …

I would like to set up an expiration notice:
I choose a date, for example, August 30th, and I would like the word PrimoN to turn red when it is 7 days before August 30th … in this case, when we arrive on August 23rd the word turns red as a warning, before 23rd the word remains green.
I thought of doing a mathematical operation: load the established date into a variable and if, making the subtraction with the current date, it equals 7, it turns red otherwise green.
Problem, the word always remains green, why??
I hope I have explained myself well >__<

This is my code:

Thanks for the thorough explanation here @pluc!

Where are the dates in those labels coming from? Did you just manually type them in as text, or are they stored somewhere else in date format?

Hi !
Do you see the word “Primo N” in the second photo? Ok, I click on “August 16,2020” and it opens a classic calendar where I choose a data.
how can I set a deadline?
Have you some example of code?

Ah, sure, thanks!

So you’ll need to parse that date so that it’s just day, month, year. Then get the current day, month, year.

These are the two values you want to get the difference of. Using the day of the month here means that there will be 12 days every year where this is true, and you just want 1.

Sorry, I don’ t understand :frowning:
I need to set a deadline that it can be in a month or more.
Can you explain it through some examples of code?

Thanks your patience!