Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2009
    Posts
    351
    Thanks
    75
    Thanked 0 Times in 0 Posts

    Sql query to return date that are not in the format of 1900-00-00

    so far i have this query..

    PHP Code:
    SELECT `dateOfBirth`
    FROM `friend_req`
    WHERE `dateOfBirth` != '0000-00-00'
    AND `dateOfBirth` != '1900'
    LIMIT 0 30 
    how do i write this query in such a way that it doesnt pick up dates like 1900-01-04 or 1900-10-01 or 1900-08-28

  • #2
    Senior Coder
    Join Date
    Dec 2005
    Location
    Slovenia
    Posts
    1,994
    Thanks
    120
    Thanked 76 Times in 76 Posts
    Found a flower or bug and don't know what it is ?
    agrozoo.net galery
    if you don't spot search button at once, there is search form:
    agrozoo.net galery search

  • #3
    Supreme Master coder! Old Pedant's Avatar
    Join Date
    Feb 2009
    Posts
    27,652
    Thanks
    80
    Thanked 4,638 Times in 4,600 Posts
    Ummm...Bubikol, the problem is that he foolishly did *NOT* store dateOfBirth as a SQL DATETIME field. Apparently he stored it as VARCHAR. So now he is hosed. He has to use ONLY string manipulation to get his answer.

    Kevin: Any chance you can change your field from VARCHAR to DATETIME, so that you *can* use all the very very useful MySQL DATE and TIME functions? Which you can't do, now.
    An optimist sees the glass as half full.
    A pessimist sees the glass as half empty.
    A realist drinks it no matter how much there is.


  •  

    Posting Permissions

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