Postgresql
在 Postgresql 中按 Jalali 日期分組
我想要
GROUP BY
jalali 的月份,所有日期在我的數據庫中保存為公曆格式,我發現以下 sql 查詢但按公曆日期分組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)
最簡單的方法是使用Team Appir 的
jalali_utils
PostgreSQL 擴展。然後你可以這樣寫你的查詢: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)