SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Nov 2005
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    WHERE DATE_FORMAT count problem

    table_1
    id, date, username
    786, 2010-11-15 17:26:00, 22905035
    787, 2010-11-29 18:26:01, 102380017
    787, 2010-11-29 18:26:08, 102380017

    $count = mysql_num_rows(mysql_query("SELECT `id` FROM `table_1` WHERE DATE_FORMAT(`date`,'%d%m%Y') = '".date('dmY')."'"));

    considering today is 29-Nov-2010...
    echo $count // ...2
    should be 2 but it is not working...

    anyone knows why?

    thanks!

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,215
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    please echo your query string so that we can see exactly what mysql sees

    in other words, resolve your php substitution and show us the actual sql generated
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Zealot
    Join Date
    Nov 2005
    Posts
    117
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    echo $count; // 0

  4. #4
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,215
    Mentioned
    58 Post(s)
    Tagged
    3 Thread(s)
    no, please echo the sql statement, starting with SELECT and ending with whatever that php function produces

    also, what is the datatype of the `date` column?
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"


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
  •