Advertisement
Help Keep Boards Alive. Support us by going ad free today. See here: https://subscriptions.boards.ie/.
If we do not hit our goal we will be forced to close the site.

Current status: https://keepboardsalive.com/

Annual subs are best for most impact. If you are still undecided on going Ad Free - you can also donate using the Paypal Donate option. All contribution helps. Thank you.
https://www.boards.ie/group/1878-subscribers-forum

Private Group for paid up members of Boards.ie. Join the club.

MYSQL question

  • 25-09-2009 06: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, Registered Users 2 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, Registered Users 2 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