将号码转换为oracle中的日期 [英] Converting number to date in oracle

查看:92
本文介绍了将号码转换为oracle中的日期的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Oracle数据库中有一个数字字段,表示自1800年12月28日以来的天数。但是我试图将其(作为另一个应用程序)选为它所代表的当前日期。我不太熟悉Oracle命令(我习惯于SQL),所以我想知道是否有人可以提供一些帮助。谢谢。



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屋!

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