You'll need to figure out the week number for the date in question.
For example:
var dt = new DateTime(...); // your datetime
var cal = new System.Globalization.GregorianCalendar();
var weekNum = cal.GetWeekOfYear(dt, CalendarWeekRule.FirstDay, DayOfWeek.Sunday);
There are different strategies for counting weeks of the year, which you specify with a CalendarWeekRule
and corresponding DayOfWeek
for the starting day of the week. You can read more here.
Once you have a week number, you can do some math to make it "bi-weekly":
int biweeklyKey = weekNum % 2;
The value will be either 0 or 1, which you can use as a key in your algorithm.