How to display records between start and end date (2 columns)

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mfaisalwarraich
    New Member
    • Oct 2007
    • 194

    #1

    How to display records between start and end date (2 columns)

    Hi everybody,

    I am trying to get the records from a mysql table where i have two column as start_date and end_date.

    i want to display a record when its start date begins, for example if the start date is 10-05-2010 (date, month, year) and if the today date is 10-05-2010, then this record should start displaying until its end_date and stop displaying if end_date gone.

    i have used some sql statements which not fulfilled my requirements.
    first one:
    Code:
    $sqlSelect = "select * from items where start_date >= '$today' and end_date<='$today';
    second one:
    Code:
     
    $sqlSelect = "select * from items where DATEDIFF(start_date, '$today') <= 0 AND DATEDIFF(end_date, '$today') >= 0 ;

    where $today=date("Y-m-d")

    im using php to achieve this. please help me. thanx
  • mfaisalwarraich
    New Member
    • Oct 2007
    • 194

    #2
    :). i think i was doing something wrong with the sql statement here is corrected statement which worked fine:

    Code:
    select * from items where start_date<='$today' and end_date>='$today'

    Comment

    Working...