oracle中的日期转换 [英] Date casting in oracle

查看:50
本文介绍了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;

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

给出结果 1/1/2017

Gives result 1/1/2017

推荐答案

您的查询正在使用日期文字.来自 Oracle 文档:

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

您可以将 DATE 值指定为字符串文字,也可以使用 TO_DATE 函数将字符或数字值转换为日期值.DATE 文字是 Oracle 数据库接受 TO_DATE 表达式代替字符串文字的唯一情况.

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.

要将 DATE 值指定为文字,您必须使用公历.您可以指定一个 ANSI 文字,如下例所示:

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'

这篇关于oracle中的日期转换的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆