Ugh, this is a nasty one.
Google analytics and such does help immensly in these situation. However, this can be useful only after implementing. To get information from old records you'll need to do it the 'old school' way.
I'm no SQL expert, but here is my suggestion bor the basic search:
SELECT * FROM mdl_log
WHERE course=[course id]
AND time >= UNIX_TIMESTAMP(DATE_SUB(NOW(), INTERVAL 6 MONTH))
AND (DAYOFWEEK(FROM_UNIXTIME(time)) = 7 OR DAYOFWEEK(FROM_UNIXTIME(time)) = 1)
AND (HOUR(FROM_UNIXTIME(time)) < 9 OR HOUR(FROM_UNIXTIME(time)) >= 17)
Since the date/time functions work with formatted time there is a lot of convertion from the timestamp in the logs.
Furthermore, I didn't include the daylight saving time option because I've only used it in PHP and have no idea how to calculate it with SQL commands.
Remember, this query is only the start. You'll need to decide how much of it will be in SQL and how much in PHP.
Either way, this will result in a (relatively) long processing time, much longer than the usual server timeout. So, if you're planning to run it throught a browser I'd suggest printing something every now and then to keep the page alive.