Lord-Nikon
Expert Member
- Joined
- Jul 22, 2008
- Messages
- 2,511
Code:
SELECT UNIX_TIMESTAMP(NOW()) AS UNIX_now,
UNIX_TIMESTAMP(CONCAT(opens_date,' ',opens_time)) as UNIX_opens,
UNIX_TIMESTAMP(CONCAT(closes_date,' ',closes_time)) as UNIX_closes
FROM random_table
WHERE UNIX_now <= UNIX_closes AND UNIX_now >= UNIX_opens
Problem : UNIX_now doesn't exist as a column.
Tried :
1. WHERE `UNIX_now` ....
2. WHERE tablename.UNIX_now
3. WHERE [UNIX_now]
Can someone please be so kind as to explain to me why I can't do this and possibly provide a solution.
I ended up doing :
Code:
SELECT UNIX_TIMESTAMP(NOW()) AS UNIX_now,
UNIX_TIMESTAMP(CONCAT(opens_date,' ',opens_time)) as UNIX_opens,
UNIX_TIMESTAMP(CONCAT(closes_date,' ',closes_time)) as UNIX_closes
FROM random_table
WHERE UNIX_TIMESTAMP(NOW()) <= UNIX_TIMESTAMP(CONCAT(closes_date,' ',closes_time))
AND UNIX_TIMESTAMP(NOW()) >= UNIX_TIMESTAMP(CONCAT(opens_date,' ',opens_time))
Last edited: