Results 1 to 3 of 3

Thread: Req help: SQL statement acting strange

  1. #1
    Guest

    Question

    The SQL statement should select only those recordsets where the month matches the month selected:

    Code:
    SELECT DateBegin, DateEnd, PTS1A, PTS1C, PTS2A, PTS2C, PTS3A, PTS3C, MeetBF, MeetEm, MeetIn, MeetPl, GroupName FROM MeetingPTS WHERE DateBegin LIKE '07/%/2000' OR '08/%/2000' ORDER BY [DateBegin] ASC
    However it fails, returning all records as if I had written:

    Code:
    SELECT * FROM MeetingPTS
    Where did I miscode? I thought the '%' acted as a wildcard?

    All fields in the Db are strings, even those as dates.

    Thanks!

    Note: I figured it out. It seems that while VB will accept "A = 0 OR 3", SQL is less forgiving of implied meanings. So for SQL the statement would be "A = 0 OR A = 3"

    I needed to rewrite the query as:

    Code:
    DateBegin LIKE '07/%/2000' OR DateBegin LIKE '08/%/2000'
    [Edited by nbtnad6 on 08-22-2000 at 03:02 PM]

  2. #2
    PowerPoster 2.0 Negative0's Avatar
    Join Date
    Jun 2000
    Location
    Southeastern MI
    Posts
    4,367
    What is the data type of the DateBegin field?

    I dont think you can use the wildcards with a date field (not 100% sure). Also if you are using MS Access you should have the date literals (#) around the dates.

    Hope this helps,

  3. #3
    Member
    Join Date
    Aug 2000
    Posts
    60
    Try the following

    SELECT * FROM [table] WHERE [field] LIKE '07/__/99'

    Underscores are used for single character wildcards.
    Barend
    JHB-SA

    Nothing is impossible, except skiing through a revolving door.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width