Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: First day of the month?

Re: First day of the month?

From: Spencer <spencerp_at_swbell.net>
Date: Wed, 27 Jun 2001 22:01:00 -0500
Message-ID: <v5x_6.292$ZD6.141251@nnrp3.sbc.net>

you want midnight of the first day of the current month ?

select trunc(sysdate,'MONTH') from dual;

"Doug O'Leary" <dkoleary_at_mediaone.net> wrote in message news:MPG.15a4439f8e8cfd769897a5_at_news.randori.com...
> Hey;
>
> One of our dbas is running a script for a manager by manually updating
> the date in the script as the first of the month. I asked him why he
> didn't have the system do that for him, then send the thing via email to
> the manager in html format. He asked how to do that - id the first day
> of the month, that is; the rest I'll have to script for him.
>
> My first pass at doing that via sql, although functional, was the height
> of ugly. The second attempt works; however, I realize it'll have a
> problem every march 1st and 2nd. The third attempt, I believe hits the
> solution right on the head; I'm wondering, though, if anyone's got any
> cleaner way to do it.
>
> I'd appreciate any feedback. Thanks for your time.
>
> Doug
>
> 2nd attempt:
>
> SQL> select last_day(sysdate - 31)+1 "Date" from dual;
>
> Date
> --------
> 06/01/01
>
> 3rd attempt:
>
> SQL> select last_day(add_months(sysdate,-1))+1 "Date" from dual;
>
> Date
> --------
> 06/01/01
>
>
> --
> -------------------
> Douglas K. O'Leary
> Senior System Administrator
> dkoleary_at_mediaone.net
>
Received on Wed Jun 27 2001 - 22:01:00 CDT

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US