PDA

Click to See Complete Forum and Search --> : Req help: SQL statement acting strange


Aug 22nd, 2000, 10:12 AM
The SQL statement should select only those recordsets where the month matches the month selected:


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:


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:


DateBegin LIKE '07/%/2000' OR DateBegin LIKE '08/%/2000'


[Edited by nbtnad6 on 08-22-2000 at 03:02 PM]

Negative0
Aug 22nd, 2000, 10:17 AM
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,

bar
Aug 22nd, 2000, 11:45 AM
Try the following

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

Underscores are used for single character wildcards.