Converting MySQL query to PostgreSQL. Order by day()?

ditto

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

        }
Andomar

MySQL's day() returns the day of the month. The PostgreSQL equivalent of that is:

GROUP BY extract(day from "date")

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related