Syntax error: Unexpected keyword WHEN

Hi I'm trying to calculate the occupancy rate of my hotel but i just can't figure out the correct form. 

This is the form I'm using and I'm receiving this error: 

Syntax error: Unexpected keyword WHEN

CASE
WHEN (PARSE_DATE('month', CHECK IN) = MONTH) AND (PARSE_DATE('month', CHECK OUT) = MONTH)
THEN CHECK OUT - CHECK IN
WHEN (PARSE_DATE('month', CHECK IN) = MONTH)
THEN DATETIME_TRUNC(CHECK IN, MONTH) + INTERVAL '1 MONTH' - INTERVAL '1 DAY' - CHECK IN
WHEN (PARSE_DATE('month', CHECK OUT) = MONTH)
THEN CHECK OUT - (DATETIME_TRUNC(CHECK OUT, MONTH) - INTERVAL '1 DAY')
ELSE 0
END + 1

0 0 286
0 REPLIES 0
Top Labels in this Space
Top Solution Authors