SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    It's been real... Forbes's Avatar
    Join Date
    Dec 2004
    Location
    Yorkshire, England
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question Grab records inserted within whole days

    Hi guys!

    I have a query whereby the bookings that are retrieved (in a particular instance) are those that were added 2 days ago:

    Code MySQL:
    (TIMESTAMPDIFF(HOUR, bookings.creation_date, NOW()) > 48)

    However, the problem is that if a delegate adds a booking at 5:01pm, one minute after the client knocks off for the day, the booking would lay unattended until the following day, which is effectively the third day.

    What they're wanting is not a measure by hours, but one by whole days. So, if the delegate adds a booking at 23:59, the booking is still within the one (first) day, rather than measuring its age based on hours.

    Sadly, I can't think of how I'd express that in a query. Any ideas? Assuming I've been able to articulate what I mean properly.

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,340
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    two days ago --
    Code:
    WHERE bookings.creation_date >= CURRENT_DATE - INTERVAL 2 DAY
      AND bookings.creation_date  < CURRENT_DATE - INTERVAL 1 DAY
    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    It's been real... Forbes's Avatar
    Join Date
    Dec 2004
    Location
    Yorkshire, England
    Posts
    676
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Perfect, thanks!


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
  •