Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to find bi-weekly dates?

Status
Not open for further replies.

esdee

Programmer
Apr 12, 2001
143
US
hi, i have this strange problem - how to detect if a date is in a bi-weekly schedule with another date?
i mean - if, say, May 16th will be part of a schedule starting Jan 1, Jan 15, Jan 29, Feb 12 etc ... ?

thanks !

------------------------
 
Does this help ?
Code:
private bool DateIsValid(DateTime dt)
{
	DateTime start = new DateTime(2007, 01, 01);

	while (start.Date <= dt.Date)
	{
		if (start.Date == dt.Date) return true;

		start = start.AddDays(14);
	}

	return false;
}
 
thanx

i implemented it with (start.days-date.days) mod 14 == 0 which is faster,
but my idea to ask this was if there might be a more generic solution

anyways...

------------------------
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top