can anyone help?
Moderator: General Moderators
can anyone help?
їcode]
$query = "SELECT * FROM people ORDER BY firstname";
ї/code]
Guys,
this query displays people details including two date coloums one named dateoflastcontact and the other called datecontactagain I want these two date coloums to appear in uk date format i.e dd/mm/yy. I have tried incorporating the DATE_format function from the php manual but it has no effect can anyone help
$query = "SELECT * FROM people ORDER BY firstname";
ї/code]
Guys,
this query displays people details including two date coloums one named dateoflastcontact and the other called datecontactagain I want these two date coloums to appear in uk date format i.e dd/mm/yy. I have tried incorporating the DATE_format function from the php manual but it has no effect can anyone help
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
the DATE_FORMAT function is a MySQL function, not a php one.
Code: Select all
SELECT DATE_FORMAT('%d/%m/%y', `your_date_name`) AS `your_date_field_name` FROM `table`- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
you can add them like so:
Code: Select all
SELECT DATE_FORMAT(...) ..., * FROM `table`Code: Select all
$query = "SELECT DATE_FORMAT(%d/%m/%y, dateoflastcontact, datecontactagain) AS dateoflastcontact, datecontactagain, * FROM people ORDER BY firstname";- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
they require seperate calls to the function.. i.e.
Code: Select all
SELECT DATE_FORMAT(...) ..., DATE_FORMAT(...) ..., * FROM `table`put it in exactly as you said it but it still doesnt work? any ideas??
Code: Select all
$query = "SELECT DATE_FORMAT('%d/%m/%y, dateoflastcontact) AS dateoflastcontact, DATE_FORMAT('%d/%m/%y, datecontactagain) AS datecontactagain * FROM people ORDER BY firstname";sorry but put in exactly as you said and I get this error message:
Error in query: You have an error in your SQL syntax near '* FROM people ORDER BY firstname' at line 1
any ideas??
Error in query: You have an error in your SQL syntax near '* FROM people ORDER BY firstname' at line 1
Code: Select all
$query = "SELECT DATE_FORMAT('%d/%m/%y', dateoflastcontact) AS dateoflastcontact, DATE_FORMAT('%d/%m/%y', datecontactagain) AS datecontactagain, * FROM people ORDER BY firstname";Code: Select all
$query = "SELECT DATE_FORMAT('%d/%m/%y', 'dateoflastcontact') AS dateoflastcontact, DATE_FORMAT('%d/%m/%y', 'datecontactagain') AS datecontactagain, * FROM people ORDER BY firstname";