With the help of M Bain I found a solution, because the number of monthes are only 6, 12, 24 and 35. So I did i like this and choosed for the special dates the last existing date:
when day( "date")='31' and month( "date" ) ='03' and "months"=6
then to_date(concat(year("date"), '-09-30' ) )
when day( "date")='31' and month( "date" ) ='05' and "...
You could replace '.qgs' by nothing '' in your expression:
replace( @project_filename , '.qgs', '')
As J.R pointed out, you could also select the whole filename, minus the last 4 characters
substr( @project_filename ,1,-4)
What a shame the to_interval expression treats each month as 30 days!
Here's an ugly expression which will do what you want:
right('0' || ((month("date")+"months"-1)%12+1) , 2),'-',
right('0' || day("date"),2)))
It breaks the date down into year, month and day, then uses ...
Not at all an elegant solution but it works. For those who are still glued to QGIS 2.18.
Let's assume there is a vector layer with the following attribute table.
So, the main idea is to select the latest date by expression. It could be feasible by means of the expression that must be pasted in 'Select feature using an expression'. And then press Select.
The issue is, that this is not a "date" format. QGIS uses the international date format which looks like this: yyyy-MM-dd. See ISO 8601 on Wikipedia.
Luckily you can re-format your string to a date using QGIS expressions and then select the maximum of it. Use this expression: