Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

MYSQL question

Options
  • 25-09-2009 6:45pm
    #1
    Closed Accounts Posts: 248 ✭✭


    Anybody know a mysql command that will select all the records within a certain time period?

    Pseudo-code:
    SELECT * FROM node between march 2009 and may 2009


Comments

  • Registered Users Posts: 8,488 ✭✭✭Goodshape


    SELECT * FROM node WHERE date >= startdate AND date <= enddate

    So you're getting all records where the date is greater than or equal to a starting point and less than or equal to an end point.

    Replace the bits in bold with whatever properly formatted dates you want. IIRC, MySQL likes the yyyy-mm-dd format.


  • Subscribers Posts: 9,716 ✭✭✭CuLT


    SELECT * FROM node BETWEEN UNIX_TIMESTAMP('2009-03-01') AND UNIX_TIMESTAMP('2009-05-31');


  • Registered Users Posts: 8,488 ✭✭✭Goodshape


    CuLT wrote: »
    SELECT * FROM node BETWEEN UNIX_TIMESTAMP('2009-03-01') AND UNIX_TIMESTAMP('2009-05-31');
    ah, that looks better :)

    actually learning proper SQL, rather than "feck it, it'll do" SQL, is one of my to-dos for the next couple months!


  • Subscribers Posts: 9,716 ✭✭✭CuLT


    Goodshape wrote: »
    ah, that looks better :)

    actually learning proper SQL, rather than "feck it, it'll do" SQL, is one of my to-dos for the next couple months!

    Sure I'm only a student of it myself too; it's one of those things that's easy to learn, but difficult to master. I've nowhere near as much knowledge of SQL and the intricacies of MySQL as I'd like to.

    Have been slowly working my way through High Performance MySQL, as well as learning bucketloads from IRLConor.


Advertisement