Comparison of ways to compute Weekdays
There are people who are willing to learn and there are people who are willing to teach. Unfortunately there are always a bunch of people who think they know it all already. These people attack anyone better than themselves instead of shutting up and letting everyone learn.
When Microsoft came to show my then employer the product that would become Access, I showed off FoxPro and was bullied and threatened into keeping quiet, just like people always do.
I put my money where my mouth is. I thought up this entire exercise to get rid of the childish loop and found even the simplest mathematics is beyond many. The advantage of thinking a simple problem through mathematically is the enormous speed. Get all the speed, with readable, maintainable code which does not even take long to write and that is a clear win.
Even though I made a small error in the first MyWeekdays, Foxite showed no politeness. No collaboration was offered. Only criticism and an attempt to belittle me. I let the numbers speak for themselves.
I fixed the error and the code was the fastest at that time.
As to those who feel Ben's was alright or, worse, those who think the 8-year-old-child loop code is good enough, I'm ashamed to think we are all supposedly equal programmers.
Novices, you can learn a lot from this code. This uses the Windows API to get high-resolution timing. Yet you only see a single declare API call. Try and understand how. It's a good method. This must run multiple times, just like a microbiologist grows a sample in a petri dish. That is science, not flat-earther misconceptions.
In this case the calculation methods are so much better than the loop or query that I had to run it 100,000 times just to get a visible measure.
Take each of the following programs and save them in a folder. There is no need to use the outmoded, outdated, cargo-cult procedure library.
Placing these modules in a program folder means they are available to your exe, just by using them in your application. The exe assembles itself, naturally. The modules will be found in the exe naturally. You can open all of these across your desk naturally.
I call this program testweekdays.prg
