DATE_format

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
nads1982
Forum Newbie
Posts: 9
Joined: Sat Feb 21, 2004 2:37 pm

DATE_format

Post by nads1982 »

I am using this so I can display a DATE type in a nice fashion.
I have the sql syntax working in mysql
However I am unsure how to retrieve it in php..
I have

Code: Select all

$SQL="SELECT DATE_FORMAT(dob,'%D %M %Y')from members WHERE idnum=$id";
$result=mysql_query($SQL,$dB);
$row=mysql_fetch_array($result);
$dob=rowї"dob"]
nads1982
Forum Newbie
Posts: 9
Joined: Sat Feb 21, 2004 2:37 pm

Post by nads1982 »

anyone?
I dunno how to call the result...
User avatar
patrikG
DevNet Master
Posts: 4235
Joined: Thu Aug 15, 2002 5:53 am
Location: Sussex, UK

Post by patrikG »

I've never used to DATE_FORMAT in a select statement, in inserts it makes sense, but why don't you just grab the content and let PHP do the formatting with [php_man]date[/php_man]?
nads1982
Forum Newbie
Posts: 9
Joined: Sat Feb 21, 2004 2:37 pm

Post by nads1982 »

found the solution in another forum..
incase anyone is looking..

Code: Select all

$SQL="SELECT DATE_FORMAT(dob,'%D %M %Y') as dob from members WHERE idnum=$id";
$result=mysql_query($SQL,$dB);
$row = mysql_fetch_array($result);
$dob = $rowї"dob"];
Post Reply