Gets the first Friday of the month

method one:

SELECT
TO_CHAR( to_date( '2020-01-01', 'yyyy-MM-dd' ), 'MM' ) || '' ||
CASE
WHEN to_char( to_date( '2020-01-01', 'yyyy-MM-dd' ), 'month' ), 'D' ) <= 6
THEN
7 - to_char ( trunc( to_date( '2020-01-01', 'yyyy-MM-dd' ), ' Month The ' ), ' D ' ) the ELSE  . 7  
the END  ||  ' number is the first Friday of the month '  the AS "First Friday" the FROM 
Dual;

Method Two:

select next_day( to_date( '2020-03-01', 'yyyy-mm-dd' ), 6 )  from dual;

Note: Every week starting from Sunday, so Sunday is 1, Monday is 2, and so on. You can specify obtain the first week of the week.


Guess you like

Origin www.cnblogs.com/gzyfj/p/12421540.html