I have a calendar/scheduler that I am coding and I want people to be able to search for the next available date via a few options. One of those options is to only search those dates that are "Monday" for example.

I have the following SQL command to retrieve data from my Access database, but it does not work.

"SELECT * FROM Appointments WHERE TimeAvail=True AND DateName(Weekday,AptDate) = 'Monday'"

or

"SELECT * FROM Appointments WHERE TimeAvail=True AND AptDate.DayOfWeek = 'Monday'"

Neither of these work (kindof as expected), but this is generally the idea that I would like.

I was also thinking of creating another database field and naming that WeekDayName and only searching for WeekDayName=Monday, but was wondering if there is a way of manipulating my SELECT command without making database changes. Any help or suggestions would be greatly appreciated.

How about trying this

"SELECT * FROM Appointments WHERE TimeAvail=True AND Format(AptDate,'dddd') = 'Monday';"
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.