Get the first day and last day of the week of the designated date

xiaoxiao2021-03-06  85

The Oracle function written for your first time is very simple, but I hope to help everyone.

create or replace function FIRST_LAST_WEEK_DAY (IN_DAY IN DATE, I IN INTEGER) return VARCHAR2 is Result VARCHAR2 (8); J INTEGER; begin / * Get first day first_last_week_day (sysdate, 0) acquired week last day of the week first_last_week_day (sysdate, 1) * / select to_char (in_day, 'd') INTO J from Dual; if i = 0 Then Result: = to_CHAR (IN_DAY - J 1, 'YYYYMMDD'); Else Result: = to_CHAR (In_Day (7 - j), 'YYYYMMDD'); endiff; return; end first_last_week_day;

转载请注明原文地址:https://www.9cbs.com/read-122725.html

New Post(0)