Skip to content

Instantly share code, notes, and snippets.

View dev-wanjihia's full-sized avatar
🏠
Working from home

Samson Wanjihia dev-wanjihia

🏠
Working from home
  • Nairobi, Kenya
View GitHub Profile
<?php
// Select all the dates in from 01 August 2018 to 31 August 2018
$dates = $this->db->query("select substring(checktime, 1, 10) as date from checkinout where substring(checktime, 1, 10) < '2018-08-31' and substring(checktime, 1, 10) > '2018-08-01' group by date;
");
foreach ($dates->result() as $date)
{
// Now select the records for the particular date.
$attendance = $this->db->query("select userid, username, times.timez as time from (select logid,userid,username, substring(checktime, 11) as timez, substring(checktime, 1, 10) as time from checkinout where substring(checktime, 1, 10) = '$date' order by timez asc) as times where times.logid = logid group by userid;");