We help IT Professionals succeed at work.
Get Started

Convert SQL Server fomulas to PL/SQL for Oracle 10G

vtrinity7
vtrinity7 asked
on
473 Views
Last Modified: 2013-12-19
Good Morning.  I have 3 date formulas from SQL Server that need to be converted to Oracle 10G syntax.  I've found that Oracle syntax does not have the Dateadd function as in SQL Server, therefore I am a bit lost on how to create the formulas.

The first formula calculates the start date of the rolling year based on the current date.  For instance today's date is 03/28/2011, therefore the start date for the rolling year range is 03/01/2010.  The formula is:
DATEADD(yy, -1, CAST(FLOOR(CAST(GETDATE() AS DECIMAL(12, 5))) -  (DAY(GETDATE()) - 1) AS DATETIME)) AS StartDate

The second formula calculates the end date of the rolling year based on the current date.  For instance today's date is 03/28/2011, therefore the end date for the rolling year range is 02/28/2011.  The formula is:
DATEADD(dd, -1, CAST(FLOOR(CAST(GETDATE() AS DECIMAL(12, 5))) -  (DAY(GETDATE()) - 1) AS DATETIME)) AS EndDate

The third and last formula is for calculating the number of hours worked during the week based on a hiredate that is in a table called rolling. The formula also utilizes the begin and end date of the rolling period from the previously mentioned formulas.   The formula is:

wkh = (((DATEDIFF(dd, roll.hiredate, roll.enddate) + 1)-(DATEDIFF(wk, roll.hiredate,roll.enddate) * 2) -(CASE WHEN DATENAME(dw, roll.hiredate) = 'Sunday' THEN 1 ELSE 0 END)-(CASE WHEN DATENAME(dw,roll.enddate) = 'Saturday' THEN 1 ELSE 0 END))*8)

Any assistance will be greatly appreciated.

Thank you in Advance.

Vasheti

Comment
Watch Question
CERTIFIED EXPERT
Most Valuable Expert 2012
Distinguished Expert 2020
Commented:
This problem has been solved!
Unlock 1 Answer and 5 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE