Is there any way to reset the date portion to the first of the month while preserving the time? For example:
2018-01-02 23:00:00 -> 2018-01-01 23:00:00
2018-04-04 10:00:00 -> 2018-04-01 10:00:00
with x as (
select to_date( '2018-01-02 23:00:00', 'yyyy-mm-dd hh24:mi:ss') as d from dual
union all
select to_date( '2018-04-04 10:00:00', 'yyyy-mm-dd hh24:mi:ss') from dual
)
SELECT d, d - trunc( d ) + trunc( d, 'MM' )
FROM x;
D D-TRUNC(D)+TRUNC(D,
------------------- -------------------
2018-01-02 23:00:00 2018-01-01 23:00:00
2018-04-04 10:00:00 2018-04-01 10:00:00
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With