Oracle date to string conversion

后端 未结 4 1220
谎友^
谎友^ 2020-12-31 12:27

I have a string column COL1 when I am doing this

SELECT TO_CHAR(TO_DATE(COL1,\'dd-mon-yy\'), \'mm/dd/yyyy\')
FROM TABLE1

The data in COL1 i

4条回答
  •  离开以前
    2020-12-31 12:45

    If your column is of type DATE (as you say), then you don't need to convert it into a string first (in fact you would convert it implicitly to a string first, then explicitly to a date and again explicitly to a string):

    SELECT TO_CHAR(COL1, 'mm/dd/yyyy') FROM TABLE1
    

    The date format your seeing for your column is an artifact of the tool your using (TOAD, SQL Developer etc.) and it's language settings.

提交回复
热议问题