I am just wondering if anyone knows if there is a performance difference between the extract and to_char functions to get the month or year from a date variable
or is there another function to simply parse the month.
I am trying to calculate the fiscal year based on a march 31 year end. This is an extract of the case statement within a select. The to_char appears to run slightly faster
CASE
WHEN EXTRACT (MONTH FROM NVL (p.per_start_date, p.payment_date)) < 4
THEN EXTRACT (YEAR FROM NVL (p.per_start_date, p.payment_date) - 365)
ELSE EXTRACT (YEAR FROM NVL (p.per_start_date, p.payment_date))
END AS fiscal_year,
versus
CASE
WHEN To_CHAR ( NVL (p.per_start_date, p.payment_date),'MM') < 4
THEN To_CHAR ( NVL (p.per_start_date, p.payment_date) - 365,'YYYY')
ELSE To_CHAR ( NVL (p.per_start_date, p.payment_date),'YYYY')
END AS fiscal_year
or is there another function to simply parse the month.
I am trying to calculate the fiscal year based on a march 31 year end. This is an extract of the case statement within a select. The to_char appears to run slightly faster
CASE
WHEN EXTRACT (MONTH FROM NVL (p.per_start_date, p.payment_date)) < 4
THEN EXTRACT (YEAR FROM NVL (p.per_start_date, p.payment_date) - 365)
ELSE EXTRACT (YEAR FROM NVL (p.per_start_date, p.payment_date))
END AS fiscal_year,
versus
CASE
WHEN To_CHAR ( NVL (p.per_start_date, p.payment_date),'MM') < 4
THEN To_CHAR ( NVL (p.per_start_date, p.payment_date) - 365,'YYYY')
ELSE To_CHAR ( NVL (p.per_start_date, p.payment_date),'YYYY')
END AS fiscal_year