I'm converting this code from MySQL into PostgreSQL. PostgreSQL doesn't have a day()
function for my Order by
to work. Is there a known solution? I'm wanting to group the results by day.
{
SELECT to_char(date, 'YYYY-mm-dd') AS date
FROM \"users exercises\"
WHERE userid = $user->id AND (date >= '$begin' AND date <= '$end')
GROUP BY day(date)
ORDER BY date
) UNION ALL (
SELECT to_char(date, 'YYYY-mm-dd') AS date
FROM \"users foods\"
WHERE userid = $user->id AND (date >= '$begin' AND date <= '$end')
GROUP BY day(date)
ORDER BY date
}
MySQL's
day()
returns the day of the month. The PostgreSQL equivalent of that is: