SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Zealot
    Join Date
    Dec 1999
    Location
    Highlands Ranch, CO
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Access SQL statement help

    I have an SQL statement which is acting funky. I can't get the result set I want.

    SelectStatement = "SELECT * FROM events WHERE (publish <= " & dateToday & " ) AND (expire_date >= "& dateToday & " ) ORDER BY first_day ASC"

    publish = date/time
    expire_date = date/time
    first_day = date/time
    dateToday = Date

    All I want are results that the
    'publish' date is before and including today
    AND
    today is equal to or less than 'expire_date'.

    These are articles that have a publish and expire date. They should be included in the result set if 'dateToday' fall in between those dates.

    I don't get any results with this query - but no errors. Am I missing something?

  2. #2
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,294
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    If it's access then the SQL statement should be:
    Code:
    strSQL = "SELECT * FROM events WHERE publish <= #" & dateToday & "# AND expire_date >= #" & dateToday & "# ORDER BY first_day ASC"
    Dates in Access need to be surrounded by # for some bizarre reason

    <edit>OK, putting this in the code tag with linebreaks makes it unreadable for some reason.....I'll make it all on one line like you had it so it can at least be readable[img]images/smilies/goof.gif[/img]</edit>
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse

  3. #3
    SitePoint Zealot
    Join Date
    Dec 1999
    Location
    Highlands Ranch, CO
    Posts
    193
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Dave - you know - I had tried this and it did not work, but I copied it straight from your post and it does work - go figure.

    Thanks so much for the help!

  4. #4
    Just Blow It bronze trophy
    DaveMaxwell's Avatar
    Join Date
    Nov 1999
    Location
    Mechanicsburg, PA
    Posts
    7,294
    Mentioned
    123 Post(s)
    Tagged
    1 Thread(s)
    Glad to help.
    Dave Maxwell - Manage Your Site Team Leader
    My favorite YouTube Video! | Star Wars, Dr Suess Style
    Learn how to be ready for The Forums' Move to Discourse


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
  •