>>>Hi,
>>>
>>>I am writing the code in C# but if I know how to do it in VFP, I can easily convert it to C#. That is, I know C# but weak in math :). And I can do this with a bunch of IF CASE and so on. But I think there should be a more concise formula.
>>>
>>>nTodayDow - today/current day Day of the week (1 to 7)
>>>nDays2Advance - variable that holds the number of days to advance, from the current day. This can be 1 to any reasonable number (e.g. 100). And I want to change the nDays2Advance given that the weekend should be skipped (Saturday and Sunday).
>>>Example:
>>>nTodayDow = 3 (Wednesday)
>>>nDays2Advance = 2
>>>So the nDays2Advance = 2 (since the weekend is too far ahead)
>>>But if nDays2Advance is 4, then it should be changed to 6, otherwise it will fall on the weekend.
>>>
>>>How can I express the above in the formula that would help me calculate nDays2Advance?
>>>
>>>TIA
>>
>>Thank you everybody who took the time to help me with this problem. The solution I implemented is to set the infinite loop (in C# while {true}), then advancing the date one day at a time. And then checking if the resulting date is Saturday/Sunday; in which case skipping the date. Until reaching the nDays2Advance that does not fall on a weekend.
>
>And I came up with this years ago:
http://fox.wikis.com/wc.dll?Wiki~Weekdays~Wiki>
>A similar solution was posed recently by Pinal Dave for SQL Server.
Thank you.
"The creative process is nothing but a series of crises." Isaac Bashevis Singer
"My experience is that as soon as people are old enough to know better, they don't know anything at all." Oscar Wilde
"If a nation values anything more than freedom, it will lose its freedom; and the irony of it is that if it is comfort or money that it values more, it will lose that too." W.Somerset Maugham