Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Mailing Lists -> Oracle-L -> RE: How to calculate Last and First Day of Month?
the first is always the first and the last may be calculated by using last_day function.
-----Original Message-----
Sent: Wednesday, January 23, 2002 4:32 PM
To: Multiple recipients of list ORACLE-L
Charlie Mengler wrote:
>
> I would have thought that the "first day of the month"
> is ALWAYS the 1st, as in 1 (ONE)!
>
> Please explain why it needs to be calculated or
> could be a value other than ONE.
>
> >
> > >>> stant_98_at_yahoo.com 01/23/02 10:35AM >>>
> > Hey guys,
> >
> > I know this is propablby easy, but I'm a bit
> > overwhelmed here this week. Can you please tell me how
> > to get first and last days of the month given SYSDATE?
> >
> > thanks a lot
> >
> > Regards
> >
Another case of 'On what day does Xmas fall this year? - on December 25th'.
I think that using the TRUNC() function with the suitable parameter must help you truncate SYSDATE to the first day of the month - perhaps TRUNC(SYSDATE, 'MM') or similar (too tired to RTFM). Then TO_CHAR with the suitable format should return whatever you want. For the last day, I presume that identifying the first day of the NEXT month and substracting 1 must simplify the 'is this 30/31/28/29' question.
-- Regards, Stephane Faroult Oriole Ltd -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: Stephane Faroult INET: sfaroult_at_oriole.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing). -- Please see the official ORACLE-L FAQ: http://www.orafaq.com -- Author: INET: lhoska_at_calibresys.com Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051 San Diego, California -- Public Internet access / Mailing Lists -------------------------------------------------------------------- To REMOVE yourself from this mailing list, send an E-Mail message to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in the message BODY, include a line containing: UNSUB ORACLE-L (or the name of mailing list you want to be removed from). You may also send the HELP command for other information (like subscribing).Received on Wed Jan 23 2002 - 16:48:07 CST