Reputation: 1628
I'm looking to convert (using Oracle) a date timestamp [2018-01-25T00:00:00.000+00:00] to a date [2018-01-24]. I've tried several formats however I can't seem to find the right one to convert it. I'm unsure of how to handle the +00:00.
Thanks in advance
Upvotes: 0
Views: 530
Reputation: 222382
It depends on what you really ask.
It you have a real Oracle timestamp
and you want a string in format 'YYYY-MM-DD'
, you can use to_char()
:
select to_char(col, 'YYYY-MM-DD') as res from mytable
If you have a string in ISO timestamp format, and you want a string as a result:
select substr(col, 1, 10) as res from mytable
If you have a timestamp
column and you want to set the time portion to 00:00:00
:
select trunc(col) as res from mytable;
This returns a value of datatype date
.
Upvotes: 1