Welcome Guest, Not a member yet? Register   Sign In
Sql query with date where clause
#8

[eluser]Todlerone[/eluser]
I was able to get this to work perfectly within the main controller, ie, no helper call.
Code:
$allpts = $this->Stats_model->all_patients();
    $lstmth=0;
    foreach ($allpts as $ap) :
        $month_sel = date('m', strtotime('-1 month'));
        $t = date("m", strtotime($ap['demo_created_on']));
        if ($t == $month_sel){
            $lstmth++;
        }
    endforeach;
    $data['new_patients_current_month'] = $lstmth;

I just want to vary the date('m', strtotime('-3 month')) line several times. How would I go about reusing this code? TY


Messages In This Thread
Sql query with date where clause - by El Forum - 03-21-2011, 02:12 PM
Sql query with date where clause - by El Forum - 03-21-2011, 02:28 PM
Sql query with date where clause - by El Forum - 03-21-2011, 02:42 PM
Sql query with date where clause - by El Forum - 03-21-2011, 03:35 PM
Sql query with date where clause - by El Forum - 03-22-2011, 12:53 PM
Sql query with date where clause - by El Forum - 03-22-2011, 12:56 PM
Sql query with date where clause - by El Forum - 03-22-2011, 01:03 PM
Sql query with date where clause - by El Forum - 03-22-2011, 01:12 PM
Sql query with date where clause - by El Forum - 03-22-2011, 01:34 PM
Sql query with date where clause - by El Forum - 03-22-2011, 02:53 PM
Sql query with date where clause - by El Forum - 07-04-2011, 07:51 PM



Theme © iAndrew 2016 - Forum software by © MyBB