For Programmers: Free Programming Magazines  


Home > Archive > Clarion > June 2006 > Attendance that goes into next year.









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Attendance that goes into next year.
Kent Baldwin

2006-06-24, 7:55 am

I need a formula that will calculate into the next year

I am using the w of year.

What I do is:

Every 3 ws the person is required to attend a meeting.

So, if he starts in w 5 of the year, he will have to attend every 3
ws, but excused the other two ws.

So, he is required to attend w 5,8,11,14... and so on.

To find this I am using the formula:

if wofyear(today()) % 3 = 0, attendance is required
else
attendance is excused
end

But, what do I do if wofyear( today()) is this year, and the
starting w was last year, or the year before that?
?

Kent Baldwin
using C5.5PEH ABC
good email address:
WENATVMPBQND@spammotel.com
pblais@odstrategies.org

2006-06-24, 7:55 am

Given that dates are an integer. 3 ws is just date + 21. I would
look at it not from a calendar but as number. You can still deal with
months and days but take that as the second part of your problem.

There are several date functions

DATE % 7 will give the day of the w
DAY() = day of the month
MONTH() = month of the year
YEAR() = the year
DATE(month, day, year) = date

With these tools you have all you can ever need.

The end of this month is always:

DATE(MONTH(TODAY()), 1 ,YEAR(TODAY()) ) - 1

Using this approach you can compute any relative date you need.

W of the year is an arbitrary date you can commute from above so
long as you know the day of the w of January 1st, the day the ws
starts, and account for leap year. If you use the YEAR() as part of
the expression then crossing yearly boundaries becomes trivial.

When look at ws you deal with YEAR - WEEK not just w and the
math gets easier. Compute the year and then compute the w. 3 ws
from today is TODAY() + 21 then use the above to compute the rest.

On Fri, 23 Jun 2006 22:00:59 -0500, Kent Baldwin
<WENATVMPBQND@spammotel.com> wrote:

>But, what do I do if wofyear( today()) is this year, and the
>starting w was last year, or the year before that?
>?

---------------------------------------
Paul Blais - Hayes, Virginia
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2009 codecomments.com