oracle 甲骨文儒略日

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/24775362/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 02:25:53  来源:igfitidea点击:

Oracle Julian day of year

sqloraclejulian-date

提问by Prmejc

how can I select Julian day of year in Oracle database?

如何在 Oracle 数据库中选择儒略日?

I tried: select to_char(sysdate, 'J') from dual; Which gives me the number of days since January 1, 4712 BC. But I would need the number of days since 1.1. of current year.

我试过: select to_char(sysdate, 'J') from dual; 这给了我自公元前 4712 年 1 月 1 日以来的天数。但我需要自 1.1 以来的天数。当年。

回答by álvaro González

If you check the TO_CHAR (datetime)documentation you get a link to "Format Models"with a comprehensive list of available formats. I guess you want this:

如果您检查TO_CHAR(日期时间)文档,您将获得一个指向“格式模型”的链接,其中包含可用格式的完整列表。我猜你想要这个:

DDDDay of year (1-366)

DDD一年中的第几天 (1-366)

回答by Christian

One way would be to use:

一种方法是使用:

select sysdate - trunc(sysdate,'yyyy') from dual

'Trunc' cuts everything except the year and returns 01/01/2014, subtracted by the sysdate returns numbers of days since 1st of january.

'Trnc' 删除除年份以外的所有内容并返回 01/01/2014,减去 sysdate 返回自 1 月 1 日以来的天数。

回答by Jeff Mergler

SELECT TO_CHAR(SYSDATE, 'DDD') from DUAL;

回答by acboone

Use sql select trunc(sysdate)+1 - trunc(sysdate,'yyyy') from dual. you will get an even number

使用sql select trunc(sysdate)+1 - trunc(sysdate,'yyyy') from dual. 你会得到一个偶数