We value your feedback.
Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!
Function code (current version): CREATE OR REPLACE FUNCTION DAYS_IN_Q(DT1 in date, DT2 in date, QE in date) RETURN number AUTHID CURRENT_USER AS DAYS number; QB date := trunc(QE,'Q'); begin if DT1>QE or DT2<QB then DAYS := 0; else DAYS := least(QE,DT2) - greatest(QB,DT1); end if; RETURN DAYS; end; --Select statement: select START_DATE ,END_DATE ,DAYS_IN_Q(START_DATE,END_DATE,to_date('2009-06-30','YYYY-MM-DD')) as "DAYS_IN_Q209" ,DAYS_IN_Q(START_DATE,END_DATE,to_date('2009-09-30','YYYY-MM-DD')) as "DAYS_IN_Q309" --What I want to do is simply my function so when I call it, it looks like: --,DAYS_IN_Q(to_date('2009-09-30','YYYY-MM-DD')) as "DAYS_IN_Q309" --(Obviously I need to write it so it only requires one parameter - That's not my problem.) from MY_TABLE
Add your voice to the tech community where 5M+ people just like you are talking about what matters.
|Use of Exception to end a Loop||3||54|
|Character matching different date formats for dates between||6||72|
|PL/SQL Two changes||7||41|
|sql server store procedure contains temp tables need to convert oracle?||3||38|