Question: Is there any way to convert mysql database date field to timestamp like strtotime in query itself?

my code:

```
  $this->db->where('effectdate >= ',$start_date);
  $this->db->where('effectdate <= ',$end_date);
  $query = $this->db->get();

```

$start\_date and $end\_date are timestamp values but database value is normal date.Is these anyway to convert date to timestamp ?
Please help.

Answer: 
1) STR\_TO\_DATE() //Convert string to date(varchar => date).

2) UNIX\_TIMESTAMP() // convert date to unix timestamp (date => timestamp).

```
$this->db->where('UNIX_TIMESTAMP(STR_TO_DATE(effectdate, "%Y-%m-%d")) >= ',$start_date);
$this->db->where('UNIX_TIMESTAMP(STR_TO_DATE(effectdate, "%Y-%m-%d")) <= ',$end_date);

```

Note : %Y-%m-%d is the date format in string column. Please replace it with your date format
Try this

```
$this->db->where('effectdate >= ',date('Y-m-d', strtotime($start_date)));
$this->db->where('effectdate <= ',date('Y-m-d', strtotime($end_date))));
$query = $this->db->get();

```