How to convert date strings to timestamp without knowing the date format

后端 未结 3 1524
时光取名叫无心
时光取名叫无心 2021-01-01 22:58

I am trying to write a query to insert a value into a timestamp with no timezone data type field. The value is coming from CSV file.

The version I am w

3条回答
  •  野趣味
    野趣味 (楼主)
    2021-01-01 23:34

    I agree with Erwin, but I would try create database function (PL/pgSQL, PL/Python or other language) that can convert various date strings into date. In Erwins answer you can see WHEN ... THEN and you can use it. Such function will be easier to test and maintain.

提交回复
热议问题