problem with displaying records between two dates

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • sejal17
    New Member
    • Dec 2007
    • 56

    problem with displaying records between two dates

    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,emont h=08,syear=2000 ,eyear=2005
    $q1="select transaction_id from transaction_mas ter 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_mas ter 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
    Recognized Expert Specialist
    • Jul 2006
    • 4259

    #2
    smonth=01,emont h=08,syear=2000 ,eyear=2005
    $q1="select transaction_id from transaction_mas ter 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

    Comment

    • sejal17
      New Member
      • Dec 2007
      • 56

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

      Comment

      • ronverdonk
        Recognized Expert Specialist
        • Jul 2006
        • 4259

        #4
        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

        Comment

        • sejal17
          New Member
          • Dec 2007
          • 56

          #5
          hii
          i have written 3 queries.
          1.select distinct charity_id from transaction_mas ter where y='$syear' and m>='$smonth';
          2.$startyear=$s year + 1;
          $endyear=$eyear - 1;
          select distinct charity_id from transaction_mas ter where y BETWEEN '$startyear' AND '$endyear'';
          forloop for every month.
          for($i=0;$i<12; $i++)
          3.select distinct charity_id from transaction_mas ter where y='$eyear' and m<='$emonth';

          Comment

          • ronverdonk
            Recognized Expert Specialist
            • Jul 2006
            • 4259

            #6
            Thanks for your explanation. See you again some time.

            Ronald

            Comment

            Working...