PC SOFT

FOROS PROFESIONALES
WINDEVWEBDEV y WINDEV Mobile

Inicio → WINDEV 2024 → How to count attendance weekly
How to count attendance weekly
Iniciado por guest, 21,ene. 2016 19:46 - 3 respuestas
Publicado el 21,enero 2016 - 19:46
I'd like to make a little routine that would produce something like this:

222221022022122

It's a little visual to tell me how consistent my students are training each week. The part I can figure out is how to cycle through the database. The data base just has records each day a student attends (this can be broken down by program as it has a filed for ProgramID)

So I need a routine that does this...

Cycle through the records by week and then determine how many classes they took that week. Then it's a simple matter of printing them out. So something like this:

For Each "Week"
Total attendance for this week
Add it to the string as a number
END

Anyone have any ideas?
Publicado el 22,enero 2016 - 01:00
Hi Joel

first, you need to loop on all the records of one student, and not on the weeks
then for each record, you do a datetoweek of the attendace date to find the matching week and you add 1 to that week
Weeks can be stored in an array, a table, or anything of the kind.

At the end, you loop on your array to build the string

Best regards
Publicado el 22,enero 2016 - 09:34
Hi

You can save a week number with a date. After that you can just do a
for each loop.

Or you can just run a querie that does the week stuff and then do a for each loop on the querie No need to use array's

regards
Allard
Publicado el 22,enero 2016 - 09:46
Joel,

I'm using an extra "dates" table for these kind of tasks. It's used to simplify the records you read. In the end you still have to loop through the recods and build your concatenated string. That part is hard to do using sql/queries.

The "dates" table hold a few fields
Date Date
Day int (1-7)
Week int (1-53)
Month is int (1-12)
Year int

You have to fill the table with records once, for each day let's say from 2010-2050

Then you can JOIN this table with others based on the date. You will then have the daynumber, week,month,year in every record, ready to use.
I.e. for calculating a sum-per-week.
A plus is that you are able to get records on days the students did not have any class