oracle oracle如何转换日期
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2194334/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
how to convert date in oracle
提问by Omnipresent
I have a date in the format of:
我有一个格式为的日期:
27-MAY-09 12.00.00.000000 AM
I want to convert it to:
我想将其转换为:
05/27/2009
I did to_char(my_date_variable, 'MM/DD/YYYY')
however that gives me character to number conversion error
to_char(my_date_variable, 'MM/DD/YYYY')
然而,我做到了,这给了我character to number conversion error
what can I do to convert this date?
我该怎么做才能转换这个日期?
my_date_variable is declared as:
my_date_variable 声明为:
my_date_variable VARCHAR2(40);
采纳答案by Adam Paynter
You must first convert my_date_variable
from VARCHAR2
to TIMESTAMP
:
你必须先转换my_date_variable
来自VARCHAR2
于TIMESTAMP
:
to_char(to_timestamp(my_date_variable), 'MM/DD/YYYY')