Connecting Tech Pros Worldwide Forums | Help | Site Map

problem with displaying records between two dates

Member
 
Join Date: Dec 2007
Posts: 56
#1: Feb 28 '08
hello everyone,
I have a problem with displaying records between two dates.Below is my designing page:

start date: combobox of month(smonth) & combobox of year(syear)
end date : combobox of month(emonth) & combobox of year(eyear)

I want the records between this month and year.i have written the below query for that:

suppose,
smonth=01,emonth=08,syear=2000,eyear=2005
$q1="select transaction_id from transaction_master where month BETWEEN '$smonth' AND '$emonth' and year BETWEEN '$syear' AND '$eyear'";

But with this query it is not displaying the record of 11/04/2004(mm/dd/yy).

i have used the below query also for that purpose:

$d1='01';
$d2='31';
$date1=$smonth."/".$d1."/".$syear;
$date2=$emonth."/".$d2."/".$eyear;
$sql="select distinct charity_id from transaction_master where redeem_date BETWEEN '$date1' AND '$date2'";

But it displays the whole records of that table.
Please suggest me the solution of this problem.
please help me on this.

Thanks in advance.

ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#2: Feb 28 '08

re: problem with displaying records between two dates


Quote:
smonth=01,emonth=08,syear=2000,eyear=2005
$q1="select transaction_id from transaction_master where month BETWEEN '$smonth' AND '$emonth' and year BETWEEN '$syear' AND '$eyear'";
and what is, according to you, the data type and value of table field 'month' and table field 'year'?

Ronald
Member
 
Join Date: Dec 2007
Posts: 56
#3: Mar 1 '08

re: problem with displaying records between two dates


thanx for your reply
but i have got the solution of it.thank u very much.
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#4: Mar 1 '08

re: problem with displaying records between two dates


Quote:

Originally Posted by sejal17

thanx for your reply
but i have got the solution of it.thank u very much.

Could you share that solution with our members? So we can learn from your experience.

Ronald
Member
 
Join Date: Dec 2007
Posts: 56
#5: Mar 3 '08

re: problem with displaying records between two dates


hii
i have written 3 queries.
1.select distinct charity_id from transaction_master where y='$syear' and m>='$smonth';
2.$startyear=$syear + 1;
$endyear=$eyear - 1;
select distinct charity_id from transaction_master where y BETWEEN '$startyear' AND '$endyear'';
forloop for every month.
for($i=0;$i<12;$i++)
3.select distinct charity_id from transaction_master where y='$eyear' and m<='$emonth';
ronverdonk's Avatar
Moderator
 
Join Date: Jul 2006
Location: The Netherlands
Posts: 4,139
#6: Mar 3 '08

re: problem with displaying records between two dates


Thanks for your explanation. See you again some time.

Ronald
Reply