By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,304 Members | 1,242 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,304 IT Pros & Developers. It's quick & easy.

problem with displaying records between two dates

P: 56
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.
Feb 28 '08 #1
Share this Question
Share on Google+
5 Replies


ronverdonk
Expert 2.5K+
P: 4,258
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
Feb 28 '08 #2

P: 56
thanx for your reply
but i have got the solution of it.thank u very much.
Mar 1 '08 #3

ronverdonk
Expert 2.5K+
P: 4,258
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
Mar 1 '08 #4

P: 56
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';
Mar 3 '08 #5

ronverdonk
Expert 2.5K+
P: 4,258
Thanks for your explanation. See you again some time.

Ronald
Mar 3 '08 #6

Post your reply

Sign in to post your reply or Sign up for a free account.