将号码转换为oracle中的日期 [英] Converting number to date in oracle
问题描述
ex:77650 = 2013年8月3日星期六
p>首先,如果你在日期数据类型中存储日期,那么你的生活会更容易。
然而,为了回答你的问题来添加在Oracle中的日期可以使用 +
运算符。首先,虽然你必须有一个约会,所以我将把1800年12月28日转换成一个日期,使用内置的 to_date
功能,然后添加数字。在你的情况下,你会想:
select to_date('1800/12/28','yyyy / mm / dd') + 77650 from dual
我设置了一个小SQL小提琴为您演示。
I have a numeric field in my Oracle database that represents the number of days since Dec 28, 1800. However I am trying to select it (for another application) as the current date it represents. I'm not too familiar with Oracle commands (I'm used to SQL), so I was wondering if anyone could provide some assistance. Thanks.
ex: 77650 = Saturday, August 3, 2013
Firstly, get this out of the way, your life would be easier if you stored dates in a date data-type.
However, to answer your question to add days to a date in Oracle you can use the +
operator.
Firstly though you have to have a date so I'll convert the 28th December 1800 into a date using to inbuilt to_date
function then add the number. In your case you would want:
select to_date('1800/12/28','yyyy/mm/dd') + 77650 from dual
I've set up a little SQL Fiddle to demonstrate for you.
这篇关于将号码转换为oracle中的日期的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!