I have a datevariable, I would like to have convert it to first day of its monh,
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
try this one
select trunc(sysdate, 'MM')firstday , trunc(last_DAY(sysdate)) lastday from dual;
Here is a good example:
select trunc(to_date('15.11.2019', 'DD.MM.YYYY'), 'MONTH') from dual;
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>
According to http://psoug.org/reference/date_func.html, this should work a dandy...
SELECT TRUNC(yourDateField, 'MONTH') FROM yourTable
select trunc(sysdate, 'mm') from dual;