SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Addict
    Join Date
    Mar 2005
    Location
    California, US
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Date > todays date

    I have this code:
    Code:
    $today = date('Y-m-d');
    $arrDates = func_query("SELECT DISTINCT companyid, date FROM company_dates WHERE date > $today ORDER by date");
    It doesnt seem to be formatted right for date to be compared to $today though. As one of my dates are 2005-06-14 and it comes up in the query.

    Is there a specific format I should be using to compare the date in the database with today's date?

    I have tried this too with the same result:
    Code:
    $arrDates = func_query("SELECT DISTINCT companyid, date FROM company_dates WHERE DATE_FORMAT(date,'%Y-%m-%D') > $today ORDER by date");
    The value in the date field of the table was inserted as 'Y-m-d' format

  2. #2
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    698
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    SELECT DISTINCT companyid, date 
    FROM company_dates 
    WHERE date > current_date 
    ORDER by date
    Depending on DBMS used you may have to use some other function for returning the current date.

  3. #3
    SitePoint Addict
    Join Date
    Mar 2005
    Location
    California, US
    Posts
    259
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    that worked. Thanks.


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •