function format_date($date = '', $format = 'M d, Y')
{
    if ($date) {
        $date = explode_date($date);
        $output = date($format, mktime(0, 0, 0, $date[1], $date[2], $date[0]));
        return $output;
    }
}
        return '';
    }
}
//http://127.0.0.1/report_pdf/appendix_report/query_report_esn_merge.php?begin=01-10-2540&end=24-10-2556  test product
$b = trim($_GET['begin']);
//echo "<br>";
$e = trim($_GET['end']);
//echo  "<br>";
##--YEAR current
$y_cur = date('Y');
//ปีัปัจจุบัน
//echo "<br>";
$dmy_cur = date('Y' . '-' . 'm' . '-' . 'd');
//วันเดิอน ปี ปัจจุบัน
//echo $y_cur;
$y_e = explode_date($e);
//echo "<br>";
#-- convert DATE ---
$b_conv = date_eng_format($b);
//echo "<br>";
$e_conv = date_eng_format($e);
//echo "<br>";
#-- convert DATE ---
if (!empty($b_conv) && !empty($e_conv)) {
    if ($y_e <= $y_cur) {
        ##--ผู้ป่วยเก่า--
        $str_old = " SELECT * FROM `04-monitoring` LEFT JOIN `tb_appendix1` ON `04-monitoring`.`HN` = `tb_appendix1`.`HN` WHERE  `04-monitoring`.`MonitoringDate` BETWEEN  '{$b_conv}' AND   '{$e_conv}'  ; ";
        //ผู้ป่วยเก่า
        $query_or = mysql_query($str_old);
        echo $check_row = mysql_num_rows($query_or);
        //จำนวนของผู้ป่วยเก่าทั้งหมด