By "posts" I must assume you mean Records.
The following script checks for the existance of records with the current date's year and creates 53 records if no such records are found:
Enter Find Mode ---clear the pause check box
Set Field[Shifts::Year ; Year ( get ( CurrentDate ) ) ]
Set Error Capture [on] ---keeps "no records found" dialog from interrupting the script
Perform Find 
If [Not Get ( FoundCount ) // no records with this year were found]
Set Variable [$Week ; value: $Week + 1 ]
Exit Loop If [$Week > 53 ]
Set Field [Shifts::Week ; $Week]
Set Field [Shifts::Year ; Year ( Get ( CurrentDate ) ) ]
You can use FileOptions to set this script to run each time that the database is opened, of if you are using FileMaker Server to host the file, you can set it to run once a day with a server schedule.
Hi again PhilModJunk
I have implemented your script, and it works very well. I have limited the week count to 52 ... (my mistake :-)
I wonder if you could help med with extending the functionality a little bit :-)
Is it possible to extend the script so that it also ..
- Auto enter the actual date for Monday of each week in a START DATE field ?
Hope it's possible
Still on FMP10 Nils
It can be done, but which Monday will be the first Monday of the year?
A week can begin in December 2012 and end in January 2013--which may require that extra week, BTW.
For such a week, is it a week in 2012 or a week in 2013?
And some years have 53 weeks.
Hello guys :-)
I agree that this is tricky. From what I understand ... the rules are as follows (keep in mind that norwegian weeks starts at Mondays)
in a given year ... if at the end of week 52 ... there are still 4 or more days left of the year .... this year gets a week 53 (because a week is defined as 4 or more days) ...... 2009 is such an example.
If there is 3 days or less left of the year at the end of week 52, we go to week 1.
Is this enough to make up the math ? :-)
That sounds pretty much like the ISO Week standard.
You may find these links useful:
Or try this calculation:
Substitute the correct date field for MyDateField in the Let function
[ Date = MyDateField ] ;
WeekOfYearFiscal ( Date ; 2) > 51 and Month ( Date ) = 1 ;
Year ( Date ) - 1 ;
If ( WeekOfYearFiscal ( Date ; 2) = 1 and Month( Date ) = 12 ; Year( Date ) + 1; Year( Date ) )
& "-" &
Right ( "0" & WeekOfYearFiscal ( Date ; 2 ) ; 2 )
Thanks for the amazing Script.
If I have done it correctly, the readout is (in text format) year-week (2012-43)
The script provided by PhilModJunk autocreates records with Year and Week numbers for me (fantastic)
My goal is to also Auto Create proper Dates into a START DATE field for each monday of each week created.
So .. still hopelessly stuck on how to embed such commands into PhilModJunks amazing script ;-)
Nils .... more confused than ever ;-)