3

I want GROUP BY jalali's month, all date save as gregorian format in my database, I found following sql query but group by gregorian date

SELECT COUNT(reserverow.id), EXTRACT(MONTH FROM reserverow.used_date) as "Month"
FROM reserverow
WHERE reserverow.used_date > '2000-09-28 01:00:00'
GROUP BY EXTRACT(MONTH FROM reserverow.used_date)

1 Answer 1

3

The easiest way to do this would be to use Team Appir's jalali_utils extension for PostgreSQL. Then you could write your query like this:

SELECT COUNT(reserverow.id), EXTRACT(MONTH FROM reserverow.used_date) as "Month"
  FROM reserverow
 WHERE reserverow.used_date > '2000-09-28 01:00:00'
 GROUP BY JALALI_PART('month', reserverow.used_date)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.