Jump to content


Photo

Adding from/to dates on where select query


  • Please log in to reply
2 replies to this topic

#1 cyprus

cyprus
  • Members
  • PipPipPip
  • Advanced Member
  • 68 posts

Posted 23 September 2006 - 10:52 PM

I have a series of checkboxes on a page/form which allows the user to dynamically build a WHERE statement.

$where = "WHERE GGroup IN ('$prodlist')";

Is it possible to add into the above a where condition to select records between two dates? Many thanks.

#2 onlyican

onlyican
  • Members
  • PipPipPip
  • Advanced Member
  • 921 posts
  • LocationHants - UK

Posted 23 September 2006 - 11:22 PM

something like
<?php
$from_date = "2006-01-01";
$to_date = "2006-09-24";
$query = "SELECT * FROM table WHERE date_added BETWEEN '".$from_date."' AND ".$to_date."'";
?>

Tell me the problem, I will try tell you the solution

#3 cyprus

cyprus
  • Members
  • PipPipPip
  • Advanced Member
  • 68 posts

Posted 24 September 2006 - 09:12 AM

Many thanks, that sorted it. Regards




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users