Hey Folks,

    The function last_day is there to handle all of that stuff, if you'll RTFM. 
Then using that and adding 1 day will always give you the first day of the next
month without all of that substringing stuff.  

    Sheesh, maybe we need a new 'obfuscated sql' contest again?  Like who can
come up with the most obscene way of calculating the 1st, or last, of the
current month from sysdate.

Dick Goulet

PS: actually the answers could be very interesting.

____________________Reply Separator____________________
Author: Stephane Faroult <[EMAIL PROTECTED]>
Date:       1/23/2002 1:31 PM

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.
> 
> >
> > >>> [EMAIL PROTECTED] 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: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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: [EMAIL PROTECTED]

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: [EMAIL PROTECTED] (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).

Reply via email to