I was doing a little bit of SQL work today as a favour for a contractor friend who wanted some processing doing within an Access SQL query. It involved using a code stored in one field that when applied a date column gives you another date
eg the code 01LL means to go to the last day of the next month, 02LL being last day in 2 months, D030 being date plus 30 days, 0215 being the 15th of 2 months hence etc...
Anyway, I tried using the SWITCH statement and it wouldn't work. But it would work if I removed a lot of the date processing that was going on.
So I split each of the processing parts in to their own columns, and sure enough each one was fine. I put each into its own SWITCH statement and again each was fine as long as there was only one conditional clause in the SWITCH statement.
Now I know that my syntax for the SWITCH statement was correct, the only thing that I can think of is that the SWITCH statement was being overloaded.
Has anyone come across anything similar? Or have I cocked up somewhere? I really hate having to use nested IIF statements for this
eg the code 01LL means to go to the last day of the next month, 02LL being last day in 2 months, D030 being date plus 30 days, 0215 being the 15th of 2 months hence etc...
Anyway, I tried using the SWITCH statement and it wouldn't work. But it would work if I removed a lot of the date processing that was going on.
So I split each of the processing parts in to their own columns, and sure enough each one was fine. I put each into its own SWITCH statement and again each was fine as long as there was only one conditional clause in the SWITCH statement.
Now I know that my syntax for the SWITCH statement was correct, the only thing that I can think of is that the SWITCH statement was being overloaded.
Has anyone come across anything similar? Or have I cocked up somewhere? I really hate having to use nested IIF statements for this
Comment