Reputation: 5
I have a t1 table having column name month I have a month column having data format December , 2017 want to convert it into first day of that specific month.
Upvotes: 0
Views: 36
Reputation:
Assuming the input is a string like 'December , 2017'
- perhaps in a column named mth
(best if it's not called month
, because that is an Oracle keyword), the easiest way to get the first of the month, in the date
data type, is
to_date(mth, 'Month , yyyy')
This is because if the day of the month is not provided, the default is the first day.
Demo:
select to_date('December , 2017', 'Month , yyyy') as first_of_mth from dual;
FIRST_OF_MTH
-------------------
2017-12-01 00:00:00
Upvotes: 1