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 2 of 2
  1. #1
    Regular Coder
    Join Date
    Sep 2007
    Posts
    137
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Question about Select Query VERY URGENT

    I have a table in mysql which i have defined as date and the values that are inserted have the following format for example : 2007-10-30 08:02:40

    My requirement is to run a select query to retrieve a particular column on a specific date ex= "SELECT columnname from tablename where columnname='$dt'";

    $sd=mysql_query($selectdate);
    $sdr=mysql_num_rows($sd);

    if($sdr > 0)
    { echo "Records found"
    }
    else {
    echo "No Records found";
    }

    This works fine only if i manually change the format of the date field to the following format = 2007-10-30

    I have more than 2000 records in the table so its not a good idea to edit the dates.

    MY QUESTION IS = without editing the value of the date and the value of the date field being 2007-10-30 08:02:40, how can i use a select query which would ignore 08:02:40 and consider 2007-10-30 ONLY.

    I need to implement this at the earliest. Any help in this regard will be greatly appreciated.

    Thanks.

  • #2
    Senior Coder timgolding's Avatar
    Join Date
    Aug 2006
    Location
    Southampton
    Posts
    1,517
    Thanks
    114
    Thanked 110 Times in 109 Posts
    I can help write a code to change the dates with php or you could use mysql code

    Code:
    mysql> SELECT DATE('2003-12-31 01:02:03');
            -> '2003-12-31'
    The date function extracts only the date part of the datetime expression.
    Last edited by timgolding; 10-30-2007 at 10:56 PM.
    You can not say you know how to do something, until you can teach it to someone else.


  •  

    Posting Permissions

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