Further factoring of date functions
Merge branch 'sql_entropy'