Home » SQL & PL/SQL » SQL & PL/SQL » Cursor to fetch first day and last day of the quarter (9i,WINDOWS)
Cursor to fetch first day and last day of the quarter [message #426863] Tue, 20 October 2009 02:34 Go to next message
kcp_pavan
Messages: 4
Registered: July 2008
Location: Mumbai
Junior Member

Hi all,

I want to write a cursor that fetche firstday and last day of a quarter from a starting point to till date...and loop through it.


For example my starting point is JUN-08..my cursor should fetch
01-JUN-2008 as first day and 31-AUG-2008 as lastday to till date.
..somethig like this.

firstday lastday
========= ===========
01-JUN-2008 31-AUG-2008
01-SEp-2008 30-NOV-2008
01-DEC-2008 28-FEb-2008
........... ..........
........... ............
01-AUG-2009 31-OCT-2009.


can anyone help me out to do this....


Thanks
pavan



Re: Cursor to fetch first day and last day of the quarter [message #426866 is a reply to message #426863] Tue, 20 October 2009 02:38 Go to previous messageGo to next message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
Get the month and use LAST_DAY function and to get first date of the month use TRUNC i.e,
select trunc(sysdate,'MM') from dual;

[Updated on: Tue, 20 October 2009 02:42]

Report message to a moderator

Re: Cursor to fetch first day and last day of the quarter [message #426869 is a reply to message #426863] Tue, 20 October 2009 02:45 Go to previous message
Frank
Messages: 7880
Registered: March 2000
Senior Member
You can use TRUNC to get the first day of the quarter
From there, you can use ADD_MONTHS to add a certain number of months.
Finally, LAST_DAY will give you the other date you are looking for.

[Updated on: Tue, 20 October 2009 02:46]

Report message to a moderator

Previous Topic: Index creation time
Next Topic: Select Data and Time and Concatenate to one Column
Goto Forum:
  


Current Time: Tue Dec 06 12:29:15 CST 2016

Total time taken to generate the page: 0.05474 seconds