|
-
May 11th, 2010, 02:42 PM
#1
[2008] Date parameter in MS Access WHERE clause - Can you show me the syntax?
Greetings Everyone,
In the TableAdapter configuration wizard I am using this query:
Code:
SELECT AttendanceID, StudentID, ClassId, DateOfClass, Absent
FROM Attendance
WHERE (DateOfClass BETWEEN #5/1/2010# AND #5/30/2010#)
Can you tell me the correct syntax to change the #5/1/2010# AND #5/30/2010# so the WHERE clause uses dteStartDate AND dteStartDate which are date variables ?
I tried this but it tells me I need to use the to_date function. dteStartDate is already a date variable so I know my syntax is wrong.
Code:
SELECT AttendanceID, StudentID, ClassId, DateOfClass, Absent
FROM Attendance
WHERE (DateOfClass BETWEEN #" & dteStartDate & "# AND #" & dteEndDate & "#)
Thanks.
Truly,
Emad
-
May 11th, 2010, 09:05 PM
#2
Re: [2008] Date parameter in MS Access WHERE clause - Can you show me the syntax?
Good question. I would think the format you tried would work in the case where you are using string variables.
Using date variables I would try omitting the # signs and see what happens.
Always use [code][/code] tags when posting code.
-
May 12th, 2010, 02:43 AM
#3
Re: [2008] Date parameter in MS Access WHERE clause - Can you show me the syntax?
or something like this:
Code:
WHERE (DateOfClass BETWEEN " & CDate(dteStartDate) & " AND " & CDate(dteEndDate))
Might need the second parameter to format it the way the DB is expecting it
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|