Mar 312015
 
CAST Function-Converting Between Timestamps and Dates

The CAST function can be used to convert a TIMESTAMP to a DATE and vice versa. First let’s convert a TIMESTAMP to a DATE. SELECT CAST(SYSTIMESTAMP AS DATE) ts_to_date FROM   dual; TS_TO_DAT ——— 31-MAR-15 To convert a DATE to a TIMESTAMP do the following. SELECT CAST(SYSDATE AS TIMESTAMP) date_to_ts FROM   dual; DATE_TO_TS ————————————————————————— 31-MAR-15 09.21.45.000000

[Read More]
Nov 172014
 

SQL query to fetch Day from date in Oracle [Suppose Date Time Field value is “17-Nov-2014 15:35:26”] Query to fetch day from date: select extract (day from to_date(’17-Nov-2014 15:35:26′, ‘DD-MON-YYYY HH24:MI:SS’)) “DAY” from dual; Output: DAY 17   SQL query to fetch Month from date in Oracle [Suppose Date Time Field value is “17-Nov-2014 15:35:26”]

[Read More]