#1
  1. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    12
    Rep Power
    0
    I want build and extract data from a mysql table by date. The problem is that my table data needs to be by date range as follows.

    Example: key field is DATE field
    row 1: 02-19-96 to 02-06-97
    row 2: 02-07-97 to 01-27-98
    row 3: 01-28-98 to 02-15-99

    and the input for the query will come from a FORM input (without range), example:
    Enter birthday
    input value could be 05-13-96

    How can I query the table and select the row with the correct range.

    Baffled newbie !

  2. #2
  3. No Profile Picture
    Contributing User
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 1999
    Posts
    114
    Rep Power
    16
    I think your best bet would be to separate your database field into two fields

    beginrange       endrange

    Then your sql:

    select * from whatever where '$birthday' >= beginrange and '$birthday' < endrange;

    (Make sure you validate $birthday with trim() and addslashes().)
  4. #3
  5. No Profile Picture
    Junior Member
    Devshed Newbie (0 - 499 posts)

    Join Date
    Apr 2000
    Posts
    12
    Rep Power
    0
    So you mean I should have two fields for date range:
    beginrange endrange
    and the query will read the range so I can pull data from that rows other fields ! Could you elaborate on the select query, will the folowing do the trick ?
    dabase: astrology table: birthday webform input=$birthday
    select * FROM astrology WHERE (trim($birthday)) >= beginrange AND '$birthday' < endrange;
    Read up about trim and addslashes but don't quite understand how to apply them here.

Similar Threads

  1. problem with date calculation
    By renato in forum PHP Development
    Replies: 2
    Last Post: December 23rd, 2003, 03:33 PM
  2. date comparison....again
    By Andrew_Smart in forum PHP Development
    Replies: 1
    Last Post: December 10th, 2003, 07:23 PM
  3. date addition problem
    By strange1 in forum PHP Development
    Replies: 3
    Last Post: October 6th, 2003, 05:01 PM
  4. Comparison with two date
    By mohsena in forum ColdFusion Development
    Replies: 1
    Last Post: August 26th, 2003, 11:33 AM
  5. ASP/Oracle(1)--date calculation & Comparison
    By teresa in forum ASP Programming
    Replies: 2
    Last Post: August 25th, 2003, 04:42 PM

IMN logo majestic logo threadwatch logo seochat tools logo