SitePoint Sponsor

User Tag List

Results 1 to 2 of 2
  1. #1
    SitePoint Zealot
    Join Date
    Apr 2004
    Location
    next to a pc connected to the poweroutlet
    Posts
    126
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Getting Certain Date

    Im trying to get a certain DAY and month from a DATE field in my table the query below

    Code:
     SELECT *
     FROM users
     WHERE MONTH(birthdate) = 6
     AND DAY(birthdate) = 16
    However this works when i take the AND DAY(birthdate) = 16 out.

    MySQL is throwing this error at me

    #1064 - You have an error in your SQL syntax. Check the manual that corresponds to your MySQL server version for the right syntax to use near '(birthdate) = 16 LIMIT 0, 30' at line 4
    I am currently using MySQL v4.0.20

    How can I get the day as well without getting the error.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,350
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    mysql doesn't have a DAY() function

    you'll want to use the DAYOFMONTH() function

    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
  •