如何使用ORACLE SQL双表中的特定日期确定当年的天数 [英] How to determine days count on the current year using a certain date on ORACLE SQL dual table
本文介绍了如何使用ORACLE SQL双表中的特定日期确定当年的天数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
例如,以YYYYMMDD作为格式的日期并同时考虑the年
For example, date with YYYYMMDD as a format and considering the leap year as well
20160201是一年中的32天
20160201 is the 32 day of the year
20160226是一年中的57天
20160226 is the 57 day of the year
20161231是一年中的366天
20161231 is the 366 day of the year
推荐答案
使用TO_CHAR
函数,'DDD'
为您提供一年中的某天:
Use TO_CHAR
function, 'DDD'
gives you the day of year:
SELECT
TO_NUMBER(TO_CHAR(DATE'2016-02-01', 'DDD')),
TO_NUMBER(TO_CHAR(SYSDATE, 'DDD')),
TO_NUMBER(TO_CHAR(DATE'2016-12-31', 'DDD'))
FROM
dual
这篇关于如何使用ORACLE SQL双表中的特定日期确定当年的天数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文