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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to get last quarter from the particular date

Status
Not open for further replies.

natncm70

MIS
Jan 16, 2002
66
IN
Hello,
I need to get Last Quarter from the particular date.Please help me. This is urgent.
Regards
 
Why not build your own Calendar table ?

Then you can add as many columns or rows representing months, quarters, etc and days in the past or future respectively.

Teradata also has a CALENDAR table - ask your DBA - but as we wanted to use our own financial calendar this wasn't too useful.

Roger...
 
What do you mean by "Last Quarter"?

If you don't want to use a calendar table, the easiest way to calculate the quarter is
(extract(month from aDate) + 2) / 3

If Last Quarter is the quarter before it's
(extract(month from add_months(aDate, -3)) + 2) / 3

Dieter
 
I need particular date's, previous quarter date, not a current quarter.
Thanks
 
I will give you an answer that I believe will solve your problem, but someone else may have a more efficient method.

Select MAX(t1.calendar_date)
From sys_calendar.calendar t1,
(select t2.quarter_of_calendar
from sys_calendar.calendar t2
where t2.calendar_date = somedate)find(qtr)
Where t1.quarter_of_calendar =
find.qtr -1
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top