Hi all.
I know that is POST has appeared in the Nb's section but on the advice of a senior member I have reposted it to the database section.
I need to write a query that will look at date fields in my table that are stored as MySql "timestamp" type. i.e. "20070411000000"
The background is this: if a person is away on holiday between x and y dates, then echo their location address. So I have this:
Not on holiday:
house No = houseno
street = street
town = town
state = state
country = country
zip = zip
On holiday
house No = a_no
street = a_street
town = a_town
state = a_state
country = a_country
zip = a_zip
Then I turn to a query. A member in the Nb’s section suggested I use "SELECT CASE, WHEN NOW() BETWEEN” but we could not get it to work.
This is what we have so far for displaying dates in a friendly format in one section of my page.
SELECT * , DATE_FORMAT(departuredate, '%d/%m/%Y') as d_date, DATE_FORMAT(accomarrivaldate, '%d/%m/%Y') as a_date, DATE_FORMAT(accomdepartdate, '%d/%m/%Y') as ac_date, DATE_FORMAT(profiledate, '%d/%m/%Y') as p_date
FROM members
WHERE member_id = colname
Included in the query how can I write something like this: an example:
If todays date is in between or = to accomarrivaldate (16-04-2007) and accomdepartdate (20-04-2007) then display “away” else display “home”
I am told that PHP will not do “between dates” so I need to look at MySQL. Can anyone help with trying to solve this?
I have never come across the "SELECT CASE, WHEN NOW() BETWEEN". Can you please help me through this. I know your time is valuable and it is much appreciated if you can. I am learning all the time.