Convert timestamp to date in Oracle SQL

前端 未结 7 2165
花落未央
花落未央 2020-12-05 23:17

How can we convert timestamp to date?

The table has a field, start_ts which is of the timestamp format:

\'05/13/2016 4:58:1         


        
7条回答
  •  甜味超标
    2020-12-05 23:41

    If the datatype is timestamp then the visible format is irrelevant.

    You should avoid converting the data to date or use of to_char. Instead compare the timestamp data to timestamp values using TO_TIMESTAMP()

    WHERE start_ts >= TO_TIMESTAMP('2016-05-13', 'YYYY-MM-DD')
       AND start_ts < TO_TIMESTAMP('2016-05-14', 'YYYY-MM-DD')
    

提交回复
热议问题