Convert Timestamp To Date In Oracle SQL


Answer :

CAST(timestamp_expression AS DATE)


For example, The query is : SELECT CAST(SYSTIMESTAMP AS DATE) FROM dual;



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')


Format like this while selecting:


to_char(systimestamp, 'DD-MON-YYYY')

Eg:


select to_char(systimestamp, 'DD-MON-YYYY') from dual;


Comments

Popular posts from this blog

Converting A String To Int In Groovy

"Cannot Create Cache Directory /home//.composer/cache/repo/https---packagist.org/, Or Directory Is Not Writable. Proceeding Without Cache"

Android SDK Location Should Not Contain Whitespace, As This Cause Problems With NDK Tools