I need to get Financial Year Month(April to March) based on Year in Postgres Query…
Like if passing 2022 then I need to get(12 month list) April-2022 to March-2023 month list.
I have tried using EXTRACT() Function date to year but not getting exact result.
3
Answers
This query generates a series of dates starting from April 1st of the specified year and ending on March 31st of the following year (a financial year). It then uses the to_char function to format these dates as "Month-YYYY" (e.g., "April-2022", "May-2022", …, "March-2023").
You can use this generally to generate the list for the financial year by changing the year:
I have replaced year to 2022 and 2023 to get the list you wanted in your example:
You will the following output:
You can as well try this query to get Financial Year Month based on Year