SitePoint Sponsor

User Tag List

Results 1 to 8 of 8
  1. #1
    SitePoint Zealot willmoss's Avatar
    Join Date
    Apr 2002
    Location
    London, England
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy Simple SQL Query ... Please help!

    Hey Everyone,

    Could someone help me? I need a SQL query for MS Access 2000 which will select records which are dated either for the current day or for the next day (the date column is called "date", formatted as Date/Time) from a table called "meetings".

    At the moment I'm using this to select meetings with today's date:
    Code:
    SELECT * FROM meetings WHERE date = 17/6/04
    The table has one row in it which has 17/6/04 (which I entered manually) in the date column but which is not selected after running the above query.

    Once I get this working, I would like to adapt it to select rows which are dated for today and tomorrow.

    What am I doing wrong?

    Thanks in advance,

    - Will

  2. #2
    SitePoint Enthusiast chuckles's Avatar
    Join Date
    Jun 2004
    Location
    Calgary
    Posts
    28
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Not too sure, but maybe try a quote?
    Code:
    SELECT * FROM meetings WHERE date = '17/6/04'

  3. #3
    SitePoint Zealot willmoss's Avatar
    Join Date
    Apr 2002
    Location
    London, England
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Thanks for the help, but I've already tried it - With quotes I get the error "Data type mismatch in criteria expression" and the query won't run at all!

  4. #4
    SitePoint Guru silver trophy zakruvalcaba's Avatar
    Join Date
    May 2003
    Location
    San Diego
    Posts
    786
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    In Design View for the table what is the data type for your date field? The data type should be Date/Time and then set the format to Short Date. Next, just modify your query so that the year has four digits like this:

    '6/17/2004'
    Zak Ruvalcaba, MCAD, MCSD
    SitePoint Author: Build Your Own ASP.NET Website using C#/VB.NET
    Sams Author: Dreamweaver MX 2004 Unleashed

  5. #5
    SitePoint Guru
    Join Date
    Jan 2004
    Location
    Uppsala, sverige
    Posts
    700
    Mentioned
    2 Post(s)
    Tagged
    1 Thread(s)
    Code:
    SELECT * FROM meetings WHERE [date] = #17/6/04#

  6. #6
    SitePoint Zealot willmoss's Avatar
    Join Date
    Apr 2002
    Location
    London, England
    Posts
    154
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up

    Great! Although zak's code didn't work, swampBoogie's did. I never knew that SQL could be so frustrating!

    Thanks for your help guys - much appreciated,

    - Will

  7. #7
    SitePoint Wizard
    Join Date
    Jul 2003
    Location
    Kent
    Posts
    1,921
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)
    You didn't know SQL could be frustrating? Is this your first ever database then?

    Wait till you start hitting your head on the desk (honest, but I put the padded wrist support in place first)

  8. #8
    SitePoint Guru silver trophy zakruvalcaba's Avatar
    Join Date
    May 2003
    Location
    San Diego
    Posts
    786
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    I don't know about you, but the front of my head is flat!
    Zak Ruvalcaba, MCAD, MCSD
    SitePoint Author: Build Your Own ASP.NET Website using C#/VB.NET
    Sams Author: Dreamweaver MX 2004 Unleashed


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
  •