We need to have a fixed starting point for calculating the 14-day periods, and, for it to return the value that you want, that starting point needs to be any Sunday.
Dates can be subtracted, so subtract the current day (or any date) from that start date to get the time difference in seconds. There are 86,400 seconds in a day, so to find the number of days between today and the first Sunday in the year, the formula is ([Today] – [Start Date]) / 86400.
Now you have the number of days between the current date and the start date. You can use the @Modulo function to divide up the time difference into 14-day periods and return the number of the day in a 14-day period. You'll need to add 1, because the first Sunday would return 0. So the formula would look something like this:
tFirstSunday := [1/2/2005]; tNumDays := (@Today - tFirstSunday) / 86400; tModulo := @Modulo(tNumDays; 14) + 1; @Prompt([OK]; ""; "Modified @Weekday value: " + @Text(tModulo));
As long as the starting point is a Sunday, you'll get a return value of between 1 and 14. (You could also just use the Saturday before the Sunday start date and not need to add 1 to the result, but it's easier to understand the code if you start with a Sunday.)
Do you have comments on this Ask the Expert question and response? Let us know.
Dig Deeper on Lotus Notes Domino Formula Language
Related Q&A from Brad Balassaitis
Upon moving to Lotus Notes 8, some Lotus Notes users received an error message stating: 'Database has not been opened yet.' Find out why here. Continue Reading
Discover what security settings you need to fix if you encounter the Lotus Notes database error: 'database is not opened yet.' Continue Reading
Learn the Formula language code that you can use if you'd like your Lotus Notes form with embedded views to stop displaying all response documents. Continue Reading
Have a question for an expert?
Please add a title for your question
Get answers from a TechTarget expert on whatever's puzzling you.