I have a datevariable, I would like to have convert it to first day of its monh,
- Eg: 10/10/2010 -> 01/10/2010
- Eg: 31/07/2010 -> 01/07/2010
I have a datevariable, I would like to have convert it to first day of its monh,
According to http://psoug.org/reference/date_func.html, this should work a dandy...
SELECT TRUNC(yourDateField, 'MONTH') FROM yourTable
SQL> select to_date('31/07/2010', 'DD/MM/YYYY') from dual;
TO_DATE('
---------
31-JUL-10
SQL> select trunc(to_date('31/07/2010', 'DD/MM/YYYY'), 'MM') from dual;
TRUNC(TO_
---------
01-JUL-10
SQL>
try this one
select trunc(sysdate, 'MM')firstday , trunc(last_DAY(sysdate)) lastday from dual;
SELECT trunc(to_date('22-AUG-03'), 'MON') FROM dual;
More in the manual.
About Oracle needing a dummy FROM
: Select without a FROM clause in Oracle
Here is a good example:
select trunc(to_date('15.11.2019', 'DD.MM.YYYY'), 'MONTH') from dual;