Convert timestamp to date in Oracle SQL

前端 未结 7 2159
花落未央
花落未央 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-06 00:03

    Try using TRUNC and TO_DATE instead

    WHERE
        TRUNC(start_ts) = TO_DATE('2016-05-13', 'YYYY-MM-DD')
    

    Alternatively, you can use >= and < instead to avoid use of function in the start_ts column:

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

提交回复
热议问题