ORACLE根據日期獲取當月的天數

2021-05-04 06:12:27 字數 486 閱讀 6423

create or replace function get_days (p_date date)

return number authid current_user

asp_days   number := 0;

begin

select ( to_date (to_char (add_months (p_date, 1), 'yyyymm'), 'yyyymm')

- to_date (to_char (p_date, 'yyyymm'), 'yyyymm')

)into p_days

from dual;

return p_days;

exception

when others

then

return 0;

end;

/

使用方法:get_days(sysdate)

根據日期獲取當月有幾天

根據日期獲取當月有幾天 declare date varchar 10 某日期 declare newdate varchar 10 下月的第一天 declare month int 當月月數 declare day int 天數 declare year int 當年年數 set date con...

04 根據日期計算當月天數

需求 給出日期,求出其當月份的天數 我們需要用到eomonth函式和day函式,在此解釋一下這兩個函式 eomonth函式 語法 eomonth start date,months 作用 返回一串日期,表示指定月數之前或者之後的月份的最後一天 舉例 當單元格a1內容為 1月1日 輸入公式 eomon...

Oracle獲取當天,當月,當年的資料

between to date to char sysdate,yyyy mm dd 00 00 01 yyyy mm dd hh24 mi ss and to date to char sysdate,yyyy mm dd 23 59 59 yyyy mm dd hh24 mi ss oracle...