Convert Date format while retaining datatype - Oracle<>
This question already has an answer here:
- Formatting DATE in oracle 1 answer
Dates don't have formats, so you can't set the format when it is saved. Formats only come into play when converting to or from a string.
If you want to save just the month year with day and time being 1 and midnight, trunc(date_value, 'month'). Fomat models for round and trunc date.
Convert it back to a date.
SELECT to_date(TO_CHAR(SYSDATE, 'YYYY-MM'),'YYYY-MM') FROM DUAL
Of course, to be a valid date there must be a day component. This will be set to 1.
Alternatively, why not just store the sysdate? Next time you look at that value you will only be interested in the year and month.