0

I have a date field in a mysql table formatted like this: Y-m-d.

I want to export every post that has a date between $fromDate and all the way to $toDate I am sure its easy but now i am totaly blocked from ideas.

I am using codeigniter if that helps.

Best Regards Audun

2
  • What format are $fromDate and $toDate in? Commented Nov 25, 2009 at 13:00
  • they are like this $toDate = $this->input->post('toDate'); that gives Y-m-d like 2009-03-23. Commented Nov 25, 2009 at 13:02

2 Answers 2

2

Try building a query similar to this and passing it to mysql_query (assuming your date format in $fromDate and $toDate match the date format of your mysql column)

<?

$query="SELECT * FROM table WHERE date BETWEEN '$fromDate' AND '$toDate'";

?>
Sign up to request clarification or add additional context in comments.

Comments

2

In CodeIgniter documentation about Active Record at http://www.codeigniter.com/userguide2/database/active_record.html, there is a sub-section with title "$this->db->where();".

You can use comparison signs (like !=, <, >, <= and >=) just after the name of the column on which condition(s) is checked. For instance :
$this->db->where('id <', $id);

$array = array('name !=' => $name, 'id <' => $id, 'date >' => $date);
$this->db->where($array);

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.