April 13, 20196 yr I'm looking for a script that will create a record for each Sunday in any given year, but I can't figure it out.
April 13, 20196 yr Start by calculating the date of the first Sunday in the given year. Then loop, creating a record for each Sunday and adding 7 days, until you reach the following year: Set Variable [ $sunday; Value:Let ( nY = Date ( 1 ; 1 ; Get (ScriptParameter ) ) ; nY + Mod ( 1 - DayOfWeek ( nY ) ; 7 ) )] Loop New Record/Request Set Field [ YourTable::Datefield; $sunday ] Set Variable [ $sunday; Value:$sunday + 7 ] Exit Loop If [ Year ( $sunday ) > Get ( ScriptParameter ) ] End Loop Commit Records/Requests where the given year is passed as the script parameter.
Create an account or sign in to comment