Page 1 of 1

dates

Posted: Wed Dec 10, 2003 9:40 am
by irealms
at the moment i am selecting by day,month and year using drop down lists, the query is

Code: Select all

<?php


$adate = ''.$_POST['yearstart'].'-'.$_POST['monthstart'].'-'.$_POST['daystart'].'';
$aorders = "SELECT orderno,username,DATE_FORMAT(dateadded, '%d-%m-%Y') AS dateadded,status FROM orders WHERE dateadded='$adate' AND archive='1' ORDER BY dateadded DESC";
		
$aordersq = mysql_query($aorders, $db_conn) or die("Query orders failed".mysql_error());
?>
how do i get it to search by month and year only? I have tried a few things and can't get it to work.
?>

Posted: Wed Dec 10, 2003 9:44 am
by aquila125

thanks

Posted: Thu Dec 11, 2003 3:05 am
by irealms
Thanks aquila it that link was great, got it working now with :

Code: Select all

<?php
$mdate = $_POST['monthstart'];
$ydate = $_POST['yearstart'];
$aorders = "SELECT orderno,username,DATE_FORMAT(dateadded, '%d-%m-%Y') AS dateadded,status FROM orders WHERE MONTH(dateadded)='$mdate' AND YEAR(dateadded)='$ydate' AND archive='1' ORDER BY dateadded DESC";

?>