×
INTELLIGENT WORK FORUMS
FOR COMPUTER PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you a
Computer / IT professional?
Join Tek-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Tek-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

How to get last quarter from the particular date

How to get last quarter from the particular date

How to get last quarter from the particular date

(OP)
Hello,
   I need to get Last Quarter from the particular date.Please help me. This is urgent.
Regards

RE: How to get last quarter from the particular date

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...

RE: How to get last quarter from the particular date

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

RE: How to get last quarter from the particular date

(OP)
I need particular date's, previous quarter date, not a current quarter.
Thanks

RE: How to get last quarter from the particular date

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    

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Tek-Tips Forums free from inappropriate posts.
The Tek-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Tek-Tips forums is a member-only feature.

Click Here to join Tek-Tips and talk with other members! Already a Member? Login


Close Box

Join Tek-Tips® Today!

Join your peers on the Internet's largest technical computer professional community.
It's easy to join and it's free.

Here's Why Members Love Tek-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close