flyalaska Posted October 16, 2017 Report Posted October 16, 2017 (edited) I ran into a wall with the monthly hub stats. I am trying to get the hours to reset every month. Shown on the red ribbon on the picture below. It only shows total hours. Here is my code. public static function TotalHoursBetweenDates($icao, $startdate, $enddate) { //Count total hours $query = "SELECT SUM(flighttime) as hours FROM phpvms_pireps WHERE depicao = '$icao' OR arricao = '$icao' AND DATE(submitdate) >= '$startdate' AND DATE(submitdate) <= '$enddate'"; $result = DB::get_row($query); return $result->hours; } <?php echo HubStats::TotalHoursBetweenDates('PACD', date("Y-m-01"), date("Y-m-t"));?> Any help would be appreciated! Edited October 29, 2017 by flyalaska Quote
web541 Posted October 17, 2017 Report Posted October 17, 2017 Haven't tried it so it might not work, but you can have a go at this. public static function TotalHoursBetweenDates($icao, $startdate, $enddate) { //Count total hours $query = "SELECT SUM(flighttime) as hours FROM phpvms_pireps WHERE depicao = '$icao' OR arricao = '$icao' AND (submitdate BETWEEN '$startdate' AND '$enddate')"; $result = DB::get_row($query); return $result->hours; } Quote
Members Vangelis Posted October 18, 2017 Members Report Posted October 18, 2017 public static function TotalHoursBetweenDates($icao, $startdate, $enddate) { //Count total hours $query = "SELECT SUM(flighttime) as hours FROM phpvms_pireps WHERE submitdate BETWEEN '$startdate' AND '$enddate' and (depicao='$icao' or arricao='$icao')"; $result = DB::get_row($query); return $result->hours; } Quote
Members Vangelis Posted October 29, 2017 Members Report Posted October 29, 2017 I am sure that this function is working as i tested it can you attach the php files that you use ? 1 Quote
flyalaska Posted October 29, 2017 Author Report Posted October 29, 2017 Its working now, I forgot a step. Thank you so much, Quote
Moderators shakamonkey88 Posted March 19, 2018 Moderators Report Posted March 19, 2018 Any idea on getting this to work? I have the total showing but I'd like to show only the current month's result. edit: Ah.. seems as though it is showing the current month's only Regards, Pete Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.