Notice based on date comparison

hi, i’m trying to do this thing but i can’t reach a result
I need to make a reminder appear to the user when an “expiration date” field is less than 30 days than today.

With ASP I did this

<% IF ((DateDiff("d",rst_scad_doc.Fields.Item("expiredate"),(now))>= -30) AND (DateDiff("d",rst_scad_doc.Fields.Item("expiredate"),(now)) <0)) THEN%>&nbsp;<span class="label label-warning" style="opacity: 1;">EXPIRING&nbsp;</span

I try to do in Wappler a similar thing.
I know it’s wrong because it does a string comparison on dates. But I don’t know where to start!

SELECT expiration 
FROM pratica 
WHERE DateDiff((d),(expiration),(:P1))>= -30

.Name: P1    Expression: date()

There’s a date formatter for adding days to a date so in your condition you should get something like this:

{{NOW.dateAdd('days', 30)}}

so your condition compares the date field as less than the above.

2 Likes

Thanks :slight_smile:

1 Like