469,647 Members | 1,788 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,647 developers. It's quick & easy.

problem with displaying records between two dates

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
5 1685
ronverdonk
4,258 Expert 4TB
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
sejal17
56
thanx for your reply
but i have got the solution of it.thank u very much.
Mar 1 '08 #3
ronverdonk
4,258 Expert 4TB
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
sejal17
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
4,258 Expert 4TB
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.

Similar topics

reply views Thread by Fronky | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.