What he ment was this
While it may work now, you should not run queries like this but use system.db.runPrepQuery
Also it seems you are doing a lot of work formating the date...
...
Anyways a simple expression function on a new custom prop should be able to refreshBindings.
But i suggest you make a cleaner query first xd