SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Member
    Join Date
    May 2010
    Posts
    8
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    How to select the matching details from table mysql query equal to current date

    Hi..,


    my question is how can i select the row in a particular given time span.

    i.e if my date field is having the entry as 2010:10:27 10:30:00 then that row should be selected when the current time reaches 2010:10:27 10:00 and until the current time reaches the 2010:10:27 18:30:00 . like that. Any help on this would do a great benefits for me..

    thanks in advance

  2. #2
    dooby dooby doo silver trophybronze trophy
    spikeZ's Avatar
    Join Date
    Aug 2004
    Location
    Manchester UK
    Posts
    13,806
    Mentioned
    158 Post(s)
    Tagged
    3 Thread(s)
    Thread moved to MySQL forum
    Mike Swiffin - Community Team Advisor
    Only a woman can read between the lines of a one word answer.....

  3. #3
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,248
    Mentioned
    59 Post(s)
    Tagged
    3 Thread(s)
    let me see if i understand your requirements...

    you want the query to return 10:30 but only between 10:00 and 18:30?

    i'm sorry, i don't understand
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  4. #4
    SitePoint Zealot
    Join Date
    Apr 2005
    Location
    London
    Posts
    163
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Quote Originally Posted by rockowtham View Post
    Hi..,


    my question is how can i select the row in a particular given time span.

    i.e if my date field is having the entry as 2010:10:27 10:30:00 then that row should be selected when the current time reaches 2010:10:27 10:00 and until the current time reaches the 2010:10:27 18:30:00 . like that. Any help on this would do a great benefits for me..

    thanks in advance
    You can use now(), to get the current datetime
    and the function date_add() to add to datetimes.

    e.g. maybe something like
    Code:
    where date_field between 
    date_add(now(), interval 30 minute)
     and
    date_add(now(), interval 8 hour)
    ;


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
  •