I’m trying to group time values in MS Access. I have a switch statement, but it says the syntax is invalid. I’m not sure why.
Switch(
[Time]<#7:00 AM#,
"Before 7:00 AM",
[Time] >= #7:00 AM# And [Time]<= #10:00 AM#,
"Morning",
[Time] >#10:00 AM# And [Time]<=#5:00 PM#,
"Late morning through Afternoon",
[Time]> #5:00 PM# And [Time]<=#10:00 PM#,
"Evening",
[Time] > #10:00 PM#,
"After 10:00 PM'
) AS Time_of_Day
The values are being stored in Short Time through an input mask, like this:
00:00
I have tried to edit the above switch statement to include long time, but it still doesn’t work. Could someone please tell me what’s wrong with the above switch statement, and whether or not this is a good way to group time values in Access/SQL.
Thanks
Is this the exact code? If you have a mismatched quote it could produce your sytax error:
Should be: