1

I'm trying to list out a table, and if a schedule date is within 2 days, to list as a warning and if the date is past today then list it as late.

I'm having trouble getting the "Between" portion of this code to function properly. The between code seems to work outside the case statement but not within. Any help is greatly appreciated.

Thanks,

SELECT schedule,
case when schedule BETWEEN(curdate(), curdate() + 2)then 1 else 0 end as 
 warning,
case when schedule < CURDATE() then 1 else 0 end as late
 from upgrade_table

error: Error code 1064, SQL state 42000: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'then 1 else 0 end as warning, case when sched < CURDATE() then 1 else 0 end as l' at line 2

RiggsFolly
  • 93,638
  • 21
  • 103
  • 149
spas2k
  • 499
  • 1
  • 6
  • 15

1 Answers1

1

The correct syntax for the BETWEEN is:

BETWEEN [FirstValue] AND [SecondValue]

Ex:

WHERE [DATE] BETWEEN Date1 AND Date2+DAY(2)
mrbitzilla
  • 368
  • 3
  • 11