Titles Listing - Query consider empty ie.endDate as lastest date

I had to use some SQL trick and changed the simple MAX(ie.endDate) with:
MAX(CASE WHEN ie.endDate IS NULL THEN '~' ELSE DATE_FORMAT(ie.endDate, '%Y/%m/%d') END)

It should replace an empty field with the character '~' which is then bigger than any date.
I also had to manage the date formatting with the SQL instead of using <g:formatDate> in the gsp.
Therefore, I've created a session variable session.appDefaultPrefs.globalDateFormatSQL='%Y/%m/%d'