First day [message #11225] |
Mon, 15 March 2004 00:48 |
Kader
Messages: 5 Registered: January 2002
|
Junior Member |
|
|
Hi Pauls,
How to find out the first day of particular month like last_day function?
Thanks
|
|
|
Re: First day [message #11226 is a reply to message #11225] |
Mon, 15 March 2004 01:15 |
Rishi
Messages: 63 Registered: January 2001
|
Member |
|
|
SQL> select add_months(last_day(sysdate),-1) + 1
from dual;
Replace sysdate variable by the date whose first day of month u want to know...
eg:-
select add_months(last_day('29/02/2004'),-1) + 1
from dual;
this will display result as 01/02/2004 if the nls_date_format is set as 'dd/mm/yyyy'
Regards
Rishi
|
|
|
|
|
Re: First day [message #11230 is a reply to message #11227] |
Mon, 15 March 2004 01:44 |
Rishi
Messages: 63 Registered: January 2001
|
Member |
|
|
Hi Vishal
I have'nt used the Trunc function.
If possible could you please give the query for the same.
It would be helpful to me if can do it some other way around as suggested by you.
Rishi
|
|
|
Re: First day [message #11234 is a reply to message #11230] |
Mon, 15 March 2004 02:05 |
Vishal
Messages: 86 Registered: August 2000
|
Member |
|
|
TRUNC takes u to start depending on the 2nd parameter -
select trunc(sysdate,'month') from dual;
will give u start of the month
Similarly
select trunc(sysdate,'year') from dual;
will give u start of the year
see TRUNC documentation for more details.
|
|
|
Re: First day [message #11241 is a reply to message #11228] |
Mon, 15 March 2004 07:52 |
pallavi
Messages: 14 Registered: April 2001
|
Junior Member |
|
|
hi,
have one more way to find out first day.
check outif u can use it.
select '01-'||to_char(sysdate,'MON-RR') from dual;
|
|
|