SitePoint Sponsor

User Tag List

Results 1 to 3 of 3
  1. #1
    SitePoint Guru downtroden's Avatar
    Join Date
    Dec 2004
    Location
    illinois
    Posts
    976
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Finding date spans within a date span (am I doing this correctly)

    I have a calendar, eventStart and eventEnd are the two key columns.

    I want to show event within the current month being shown. The following is what I came up with for the search statement (between statements are being generated by application server). Is this correct?

    Code SQL:
    SELECT *
    FROM events 
    WHERE ( events.calendarId = ? ) 
    AND (eventStart BETWEEN {ts '2011-06-01 00:00:00'} AND {ts '2011-06-30 00:00:00'} 
    AND eventEnd BETWEEN {ts '2011-06-01 00:00:00'} AND {ts '2011-06-30 00:00:00'})

    thanks for any critiques/advice
    your brain reacts in the same way whether you are
    looking at something or thinking about it...

  2. #2
    SQL Consultant gold trophysilver trophybronze trophy
    r937's Avatar
    Join Date
    Jul 2002
    Location
    Toronto, Canada
    Posts
    39,336
    Mentioned
    63 Post(s)
    Tagged
    3 Thread(s)
    you've missed a couple of scenarios

    have a look at this thread -- http://www.sitepoint.com/forums/data...ql-664040.html

    your problem is practically identical

    rudy.ca | @rudydotca
    Buy my SitePoint book: Simply SQL
    "giving out my real stuffs"

  3. #3
    SitePoint Guru downtroden's Avatar
    Join Date
    Dec 2004
    Location
    illinois
    Posts
    976
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    on one hand, i appreciate the help… on the other i'm smacking myself in the face for not thinking of that.

    Simple answers are always the most painful for me to receive (reason mentioned above).

    Thanks
    your brain reacts in the same way whether you are
    looking at something or thinking about it...


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
  •