The first Friday of a month/quarter/year

 

Example

Write SPL script:


A

1

>n=5

2

=pdate@w(pdate@m(date("2021-05-01"))+6-n)+n

3

=pdate@w(pdate@q(date("2021-05-01"))+6-n)+n

4

=pdate@w(pdate@y(date("2021-05-01"))+6-n)+n

A1 n represents the day of the week, and Sunday is 0, followed by +1

 

A2 First use pdate@m to find the first day of the month, then add 6-n days to this day, and then find the Sunday +n days of the date. The result is: 2021-05-07

 

A3 First use pdate@q to find the first day of the quarter, then add 6-n days to this day, and then find the Sunday +n days of the date. The result is: 2021-04-02

 

A4 First use pdate@y to find the first day of the year, then add 6-n days to this day, and then find the Sunday +n days of the date. The result is: 2021-01-01