This content has been marked as final. Show 7 replies
There's an in-built SQL function to do this.
Function Name: TRUNC
SQL> SELECT TRUNC(TO_DATE('17-DEC-2001'),'YEAR') "First Day" FROM Dual;
SQL> SELECT TRUNC(SysDate,'YEAR') "First Day" FROM Dual;
For more info
Wondering if there is any such query to get last day of year also ?
Here's the query to get last day of the year
SQL>select last_day(add_months(sysdate,12 - to_number(to_char(sysdate,'mm')))) from dual;
The query also works without use of to_number function but I prefer not to depend on implicit data conversion.
That's great. Its not even 9' in the morning and I have already learnt something.
Thanks guys for all the help.
An easier way to get the last day of the year
select ADD_MONTHS(trunc(sysdate,'YEAR'),12)-1 from dual
Message was edited by:
the sql statement will be
select trunc(to_date('18-sep-2006','dd-mon-yyyy'),'year') from dual;
SELECT round(sysdate,'YYYY'),add_months(trunc(sysdate,'YYYY')-1,12) from dual