简体   繁体   中英

Date casting in oracle

How does following query work , could not find documents explaining how following query works.Are there any other similar queries for casting values?

SELECT date '2017-01-01' FROM dual;

Gives result 1/1/2017

Your query is using a date literal. From the Oracle documentation :

You can specify a DATE value as a string literal, or you can convert a character or numeric value to a date value with the TO_DATE function. DATE literals are the only case in which Oracle Database accepts a TO_DATE expression in place of a string literal.

To specify a DATE value as a literal, you must use the Gregorian calendar. You can specify an ANSI literal, as shown in this example:

DATE '1998-12-25'

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM