-
Ok Got it sorted now :-)
It just needed the AS bit; below is the full query:
$result = mysql_query("SELECT destination, DATE_FORMAT(departureDate, '%d/%m/%Y') as formattedDate FROM entries WHERE departureDate >= '$dep3' and DepartureDate <= '$dep3' + INTERVAL '7' DAY
");
Thanks for your help and advise :-)
-
I got it sorted now :-)
It just needed the AS part
this is the query:
$result = mysql_query("SELECT destination, DATE_FORMAT(departureDate, '%d/%m/%Y') as formattedDate FROM entries WHERE departureDate >= '$dep3' and DepartureDate <= '$dep3' + INTERVAL '7' DAY
");
Many thanks for your help and advice :-)
-
You don't need the AS part, you can also do
PHP Code:
$result = mysql_query("SELECT destination, DATE_FORMAT(departureDate, '%d/%m/%Y') FROM entires WHERE departureDate >= '$dep3' AND departureDate <= '$dep3' + INTERVAL '7' DAY");
while($row = mysql_fetch_assoc($result))
{
echo $row['DATE_FORMAT(departureDate, \'%d/%m/%Y\')'];
}
But as you can see, that's rather hard to read, and you have to change the PHP if you ever change the date format.
So it's easier to use "AS formattedDate" and then use $row['formattedDate']
:)
-
ok thanks
I ll bear that in mind :-)