Jump to content

how do i display all database entries between two dates


jbrill

Recommended Posts

I have two dates in a form " startdate" and enddate"

 

when i display the results i would like to show all results between, and including the two dates. how do i do this... this is my current query:

 

My Variables:

 

$userid = $_GET['idr'];

$fromdate = $_GET['fromdate'];

$todate = $_GET['todate'];

 

The query:

 

$result = mysql_query("SELECT date, status, time, notes FROM timeclock WHERE userid='".$userid."' ORDER  BY time");

 

 

my mysql querying isnt the greatest but try this:

 

$result = mysql_query("SELECT date, status, time, notes FROM timeclock WHERE userid='".$userid."' AND date BETWEEN {$fromdate} AND {$todate} ORDER  BY time");

 

but your date formats have to be the same, i think. hope that helps.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.