Welcome Guest, Not a member yet? Register   Sign In
How to select date(with custom format) in mysql table
#1

[eluser]LoganPHP[/eluser]
hi i’m trying to use mysql date_format with CI Active records method $this->db->setect() to select but getting mysql syntax error.....

so any help me..How to select date with custom format from mysql table date(date type) column?

Thanks in advance
Logan
#2

[eluser]CI_avatar[/eluser]
if you have problems with CI date_format please use the php date().
#3

[eluser]LoganPHP[/eluser]
i got solution.........

Code:
$query = $this->db->query("Select job_title,date_format(job_date,'%d-%m-%Y') as job_date,job_description,contact FROM jobs_management  LIMIT $offset, $limit");

Example with pagination:
Code:
function select_pagination($limit, $offset)
    {
        if($offset>1)
        {
            $offset=$offset;
        }
        else
        {
            $offset=0;
        }
        $query = $this->db->query("Select job_title,date_format(job_date,'%d-%m-%Y') as job_date,job_description,contact FROM jobs_management  LIMIT $offset, $limit");
        return $query->result();
    }




Theme © iAndrew 2016 - Forum software by © MyBB