Home » RDBMS Server » Server Administration » First date of the current month
First date of the current month [message #371245] Fri, 22 September 2000 12:11 Go to next message
Salman Khan
Messages: 51
Registered: September 2000
Member
Hi,

Is there any function which give the first date of the month. I know there is last_day function but Iam looking for first day.

Like 1-Sep-00

Thanks in Advance
Salman Khan
Re: First date of the current month [message #371247 is a reply to message #371245] Fri, 22 September 2000 12:22 Go to previous messageGo to next message
Salman Khan
Messages: 51
Registered: September 2000
Member
ohh, its so simple

select (last_day(sysdate)-30)+1

Anyway if you have anything like that please post it here.

Thanks
Salman Khan
Re: First date of the current month [message #371248 is a reply to message #371245] Fri, 22 September 2000 12:26 Go to previous messageGo to next message
Suresh
Messages: 189
Registered: December 1998
Senior Member
There is no direct function to get desired result.
but you can get the result by using following query
select last_day(add_months(sysdate,-1))+1 from dual

Suresh
Re: First date of the current month [message #371249 is a reply to message #371247] Fri, 22 September 2000 12:30 Go to previous messageGo to next message
Suresh
Messages: 189
Registered: December 1998
Senior Member
Your query fails when month have 31 days and sysdate is 31st of that month

Suresh
How about that one [message #371251 is a reply to message #371249] Fri, 22 September 2000 15:36 Go to previous messageGo to next message
Salman Khan
Messages: 51
Registered: September 2000
Member
How about that statment. Let me know if its still wrong.

Thanks
Salman Khan

select (last_day(sysdate)-30)+decode(substr(last_day(sysdate)-30,1,2),31,+1,-1) from dual
Re: First date of the current month [message #371252 is a reply to message #371245] Fri, 22 September 2000 16:08 Go to previous messageGo to next message
Vjeko
Messages: 15
Registered: August 2000
Junior Member
select trunc(sysdate,'Month') from sys.dual;
Re: How about that one [message #371254 is a reply to message #371249] Sat, 23 September 2000 01:22 Go to previous messageGo to next message
Mahesh Pednekar
Messages: 28
Registered: August 2000
Junior Member
BEST IS THIS...
select trunc(sysdate,'Month') from dual;
thanx
intersting one [message #371286 is a reply to message #371249] Thu, 28 September 2000 04:00 Go to previous messageGo to next message
Rajendra
Messages: 23
Registered: September 2000
Junior Member
why not try this one.
select decode(substr(last_day(sysdate),1,2),'30',last_day(sysdate-30)+1,
'31',last_day(sysdate-31)+1,'28',last_day(sysdate-28)+1,'29',last_day(sysdate-29)+1,null) from dual
enjoy...
Rajendra
Re: First date of the current month [message #371314 is a reply to message #371245] Tue, 03 October 2000 03:25 Go to previous message
Raghavendra M.K.
Messages: 10
Registered: September 2000
Junior Member
use trunc(datecolumn,'MON') FROM DUAL
Previous Topic: 8.1.5 and wildcards
Next Topic: Re: Regarding internal Mechanism of oracle
Goto Forum:
  


Current Time: Thu Mar 28 23:44:24 CDT 2024