substring query in codeigniter
Codeigniter 2021-10-30
Contoh Code :
$this->db->select('SUBSTRING(zsmonth, 5, 2) as month', FALSE)
->from('tblsales_month');
Contoh Code Lain :
public function count_setor_bulan()
{
$bulan = date('Y-m');
$this->db->select_sum('value');
$this->db->join('t_nasabah', 't_nasabah.kd_nasabah = t_transaksi.kd_nasabah');
$this->db->where('jenis_trans','Setor');
$this->db->where('SUBSTRING(tanggal, 1, 7)=',$bulan);
$query = $this->db->get('t_transaksi');
if($query->num_rows()>0)
{
return $query->row()->value;
}
else
{
return 0;
}
}
Referensi : https://stackoverflow.com/questions/20486162/substring-query-in-codeigniter