Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Is there difference between functions extract and to_char

Status
Not open for further replies.

mdl2

Programmer
Apr 12, 2002
25
0
0
CA
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

 
If one is faster, then it's faster...
Mufasa's 1st Rule said:
One test with worth 100 expert opinions.

[santa]Mufasa
(aka Dave of Sandy, Utah, USA)
[I provide low-cost, remote Database Administration services: www.dasages.com]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top