Click to See Complete Forum and Search --> : 1st Day of the Month - SQL*Plus


aph
07-20-2005, 12:05 PM
Hi All,

How I can get the 1st day of the month, I mean let's say today date is 20-JUL-05 and I need 01-JUL-05.

Thanks in advance

aph
07-20-2005, 01:19 PM
No problem; I got it. below is the solution

SELECT '01-'||to_char(sysdate,'MON-YY') FROM DUAL

eddieawad
07-20-2005, 01:50 PM
No problem; I got it. below is the solution

SELECT '01-'||to_char(sysdate,'MON-YY') FROM DUAL

Here is a more elegant yet simple solution that returns a date instead of a string:

select trunc(sysdate,'mon') first_of_month
from dual

If you still want the date as a formatted string:

select to_char(trunc(sysdate,'mon'),'DD-MON-YY') first_of_month
from dual