Home » SQL & PL/SQL » SQL & PL/SQL » To get the first day of the month
To get the first day of the month [message #202743] Sat, 11 November 2006 11:02 Go to next message
ab_trivedi
Messages: 460
Registered: August 2006
Location: Pune, India
Senior Member
Hi Littlefoot and all,

I did a query to find out the first day of the current month. the query is :

select to_date((to_char(sysdate,'dd') - to_char(sysdate-1,'dd'))||to_char(sysdate,'/mm/rrrr'),'dd/mm/rrrr')
from dual;

Please if possible then send me some easier way to do it.

Bye
Ashutosh Trivedi






Re: To get the first day of the month [message #202749 is a reply to message #202743] Sat, 11 November 2006 12:55 Go to previous messageGo to next message
Frank
Messages: 7880
Registered: March 2000
Senior Member
trunc(<date>, <datetime-unit>)
will truncate <date> to the given <datetime-unit>. If you would provide 'MM' or 'Month' as datetime-unit, it would return the first of the month of <date>.
Default <datetime-unit> is 'DD', meaning it will round back to 00:00:00 hours
Re: To get the first day of the month [message #202753 is a reply to message #202749] Sat, 11 November 2006 13:10 Go to previous message
ab_trivedi
Messages: 460
Registered: August 2006
Location: Pune, India
Senior Member
Hi Frank,

I just forget the trunc will give the result so sorry to trouble you.I am very thankfull to you.

Bye
Ashu
Previous Topic: Date formatting on table creation
Next Topic: Alter Type Error
Goto Forum:
  


Current Time: Sat Dec 03 15:55:43 CST 2016

Total time taken to generate the page: 0.07936 seconds