Hi all,
I can't get my head around this, what I am trying to do is;
If the current date is in between accomarival AND accomdepartdate THEN 'Away' ELSE 'Home' END AS loc, or if the current date is in between a_arrival_2 AND a_depart_2 THEN 'Away' ELSE 'Home' END AS loc2, the code I am using id this.
SELECT *, CASE WHEN CURDATE()
BETWEEN accomarival AND accomdepartdate
THEN 'Away' ELSE 'Home' END AS loc,
OR a_arrival_2 AND a_depart_2
THEN 'Away' ELSE 'Home' END AS loc2,
DATE_FORMAT(departuredate, '%d-%m-%Y') as d_date,
DATE_FORMAT(accomarival, '%d-%m-%Y') as a_date,
DATE_FORMAT(accomdepartdate, '%d-%m-%Y') as ac_date,
DATE_FORMAT(profiledate, '%d-%m-%Y') as p_date,
DATE_FORMAT(a_arrival_2, '%d-%m-%Y') as a2_date,
DATE_FORMAT(a_depart_2, '%d-%m-%Y') as d2_date
FROM members
WHERE member_id = colname
I can get the following to work
SELECT *, CASE WHEN CURDATE()
BETWEEN accomarival AND accomdepartdate
OR a_arrival_2 AND a_depart_2
THEN 'Away' ELSE 'Home' END AS loc,
DATE_FORMAT(departuredate, '%d-%m-%Y') as d_date,
DATE_FORMAT(accomarival, '%d-%m-%Y') as a_date,
DATE_FORMAT(accomdepartdate, '%d-%m-%Y') as ac_date,
DATE_FORMAT(profiledate, '%d-%m-%Y') as p_date,
DATE_FORMAT(a_arrival_2, '%d-%m-%Y') as a2_date,
DATE_FORMAT(a_depart_2, '%d-%m-%Y') as d2_date
FROM members
WHERE member_id = colname
but when I try to change this part i get an error.
BETWEEN accomarival AND accomdepartdate
THEN 'Away' ELSE 'Home' END AS loc,
OR a_arrival_2 AND a_depart_2
THEN 'Away' ELSE 'Home' END AS loc2,
Can anyone see where I am going off track.