faqts : Computers : Programming : Languages : PHP : Database Backed Sites : General

+ Search
Add Entry AlertManage Folder Edit Entry Add page to http://del.icio.us/
Did You Find This Entry Useful?

14 of 19 people (74%) answered Yes
Recently 6 of 10 people (60%) answered Yes

Entry

How can I select rows within a certain date range?

Aug 10th, 1999 23:15
Nathan Wallace, Jason Brooke


It depends on how you're storing your dates, but the following should
give you some ideas:

    select messagefield
    from   tablename
    where  datefield between $startdate and $enddate

or:

    select messagefield
    from   tablename
    where  datefield >= $startdate and datefield <= $enddate

or:

    select messagefield
    from   tablename
    where  datefield > $startdate and datefield < $enddate

(same as second one but adjust $startdate and $enddate to be just
outside the boundaries you seek - might help make sql faster, dunno)