In the attribute table I have a column "the end of the contract" with date. I want QGIS to show me the label "!" when there will be 30 days or less until the end of the contract.
I Would like to expand on Ian's answer and the comment you made:
You have to convert the
now() also into a date because
now() also holds the current time. This will yield an
interval. So you convert it into
day and get an integer value which can be compared.
The final query looks like this:
if( day( to_date( '2019-02-26') - to_date(now())) <30, '!', 'Some other Label')
The date in here can be any field which holds a valid date
Edit: For labeling you should try:
day( to_date( '2019-02-26') - to_date(now())) <30
and as label insert your '!' as in this screenshot
You can use an expression to control when a label is shown, so in this case you could use something like
DateCol - Now() < 30
To turn on a ! label.