Home » SQL & PL/SQL » SQL & PL/SQL » Any function of oracle to return the quarter of sysdate
Any function of oracle to return the quarter of sysdate [message #432159] Sun, 22 November 2009 05:30 Go to next message
shabir46
Messages: 40
Registered: November 2009
Member
Hi All,

Is there any built in function in oracle which will directly give the quarter of sysdate?

For eg: if sysdate is DEC - 2009, then the function should return 4 as the output.




Thanks
Shabir Kaithayil
Re: Any function of oracle to return the quarter of sysdate [message #432160 is a reply to message #432159] Sun, 22 November 2009 06:06 Go to previous messageGo to next message
Michel Cadot
Messages: 63808
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/sql_elements004.htm#i34924

Regards
Michel
Re: Any function of oracle to return the quarter of sysdate [message #432446 is a reply to message #432159] Tue, 24 November 2009 05:15 Go to previous messageGo to next message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
Hint:
Ved@orcl>  select CEIL(12/3) FROM DUAL;

 CEIL(12/3)
----------
         4

Use format model ('MM') to get the month value

[Updated on: Tue, 24 November 2009 05:15]

Report message to a moderator

Re: Any function of oracle to return the quarter of sysdate [message #432448 is a reply to message #432446] Tue, 24 November 2009 05:20 Go to previous messageGo to next message
Michel Cadot
Messages: 63808
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
Use format model ('MM') to get the month value

This is NOT what is asked.
I think you also take profit to read the link I posted.

I also think you should read the whole topic (above all when there are only 2 posts) before getting wrong as your answers become more and more.

Regards
Michel
Re: Any function of oracle to return the quarter of sysdate [message #432454 is a reply to message #432448] Tue, 24 November 2009 05:52 Go to previous messageGo to next message
pablolee
Messages: 2813
Registered: May 2007
Location: Scotland
Senior Member
Michael, that seems a little harsh.
Ved has clearly tried to provide hints rather than the solution.
The overall post from ved, if put together as intended, will actually return the result required by the op. It would be a massively over convoluted tactic, but it would do the job.
Re: Any function of oracle to return the quarter of sysdate [message #432458 is a reply to message #432448] Tue, 24 November 2009 05:56 Go to previous messageGo to next message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
 1*  select CEIL(TO_NUMBER(to_char( SYSDATE,'MM'))/3) FROM DUAL
ved@orcl> /

CEIL(TO_NUMBER(TO_CHAR(SYSDATE,'MM'))/3)
---------------------------------------
                                      4


Sir, I first wanted to put the solution. But ...
Its you who once told me not to provide solution but hint.And I just did that.

[Updated on: Tue, 24 November 2009 05:58]

Report message to a moderator

Re: Any function of oracle to return the quarter of sysdate [message #432460 is a reply to message #432458] Tue, 24 November 2009 06:00 Go to previous messageGo to next message
pablolee
Messages: 2813
Registered: May 2007
Location: Scotland
Senior Member
Its_me_ved wrote on Tue, 24 November 2009 11:56
Sir, I first wanted to put the solution. But ...
Its you who once told me not to provide solution but hint.And I just did that.

And good on you for doing that, the problem is that it's not the best solution. Have a look at the documentation link that Michel posted. The most appropriate solution can be gleaned from there

[Updated on: Tue, 24 November 2009 06:01]

Report message to a moderator

Re: Any function of oracle to return the quarter of sysdate [message #432461 is a reply to message #432159] Tue, 24 November 2009 06:01 Go to previous messageGo to next message
shabir46
Messages: 40
Registered: November 2009
Member
Hi All,

Thanks for all your reply,

TO_CHAR(SYSDATE,'Q') FROM DUAL have returned the required result.

The link provided my Micheal below is very useful

Thanks
Shabir kaithayil
Re: Any function of oracle to return the quarter of sysdate [message #432463 is a reply to message #432460] Tue, 24 November 2009 06:07 Go to previous messageGo to next message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
the problem is that it's not the best solution


Sir,
And..I never said it was a best one. I just tried. My problem is that I can not remember each and every word of the documentation.
When the OP asked for it , I just felt that I should try something and thats what I did.

TO_CHAR(SYSDATE,'Q') FROM DUAL

@Michel Sir, Thanks ...



Re: Any function of oracle to return the quarter of sysdate [message #432464 is a reply to message #432463] Tue, 24 November 2009 06:09 Go to previous messageGo to next message
Michel Cadot
Messages: 63808
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Quote:
..I never said it was a best one. I just tried. My problem is that I can not remember each and every word of the documentation.

But you can read what is posted before posted yourself, including the links. And if you have a better than post it.

Regards
Michel
Re: Any function of oracle to return the quarter of sysdate [message #432467 is a reply to message #432464] Tue, 24 November 2009 06:12 Go to previous message
Its_me_ved
Messages: 979
Registered: October 2009
Location: India
Senior Member
Yes It is..
My apologies!!! Thought that it was a link which talks about format model.

Next time I will read the entire doc link you will provide Smile

Previous Topic: un-known table in schema
Next Topic: Coverting time to number and subtracting the two
Goto Forum:
  


Current Time: Wed Sep 28 17:42:48 CDT 2016

Total time taken to generate the page: 0.07708 seconds