Welcome Guest, Not a member yet? Register   Sign In
problems on summing for a range of data in the model query, codeigniter 3
#1

Hi! I find myself in the need to add the hours extracted only on a range of dates (only the months taken individually of the year), in the traditional formula of mysql this thing I can do through the query, for example let's take the month of May:

SELECT SUM (table_time) AS total FROM table_name WHERE table_date> = '2021-05-01' AND table_date <= '2021-05-31';

my problem is the following, in active record on codeigniter 3 how should i structure the model query? I was thinking something like:

  $ this-> db-> select ("SUM (hours) AS total");
    $ this-> db-> from ("uw_planner");

    $ this-> db-> where ('data', '2021-01-01> = 2021-01-31');

    $ query1 = $ this-> db-> get ();
    if ($ query1-> num_rows ()> 0) {
      $ res = $ query1-> row_array ();
      return $ res ['total'];
    }
    return 0.00;
  }

but with $ this-> db-> where ('data', '2021-05-01> = 2021-05-31'); can't I get anything? How can I solve? Basically I can't tell the query with active record just extract the hours on the dates going from the beginning of the month to the end of the month, thanks in advance for any suggestions

ths Enricof
Reply


Messages In This Thread
problems on summing for a range of data in the model query, codeigniter 3 - by enricof - 06-05-2021, 08:02 AM



Theme © iAndrew 2016 - Forum software by © MyBB