Generate consecutive Sundays

Example

Generate the Sunday sequence from 2020-02-01 to 2020-04-30, and the result is shown in the following figure:

undefined

Write SPL script:


A

1

>start=date("2020-02-01")

2

=pdate@w(start)

3

>start=if(A2<start,A2+7,A2)

4

=periods@x(start,"2020-04-30",7)

 

A1 Define the variable start as the start date 2020-02-01

 

A2 Calculate the Sunday of the week of the start date, option @w means get the Sunday of the week of the specified date

 

A3 If A2 is less than the start date, let start be A2+7, which is the next Sunday, otherwise let start be A2

 

A4 Generate a date sequence with a 7-day interval between the start Sunday start and the end date 2020-04-30, that is, a sequence of consecutive Sundays within the specified start and end time period. The option @x means that the backend date is not included 2020-04-30