Re: Date_Format Question

From: Date: Thu, 30 Aug 2001 16:04:38 +0000
Subject: Re: Date_Format Question
Groups: php.db 
Request: Send a blank email to php-db+get-11994@lists.php.net to get a copy of this message
Thanks for the help Christopher and boclair. I think my problem was putting single quotes around the field name within the parenthesis: select date_format('creation_date', '%b %D, %Y') from Chart_Users; This works: select date_format(creation_date, '%M %D, %Y') from Chart_Users; or select date_format(creation_date, '%M %D, %Y') as creation from Chart_Users; Jeff Oien > Jeff, > > mysql> select now(); > +---------------------+ > | now() | > +---------------------+ > | 2001-08-29 21:21:50 | > +---------------------+ > 1 row in set (0.00 sec) > > mysql> SELECT DATE_FORMAT(NOW(), '%b %D, %Y') AS 'Formatted Current > mysql> Time'; > +------------------------+ > | Formatted Current Time | > +------------------------+ > | Aug 29th, 2001 | > +------------------------+ > 1 row in set (0.00 sec) > > mysql> SELECT DATE_FORMAT(NOW(), '%M %d, %Y') 'Formatted Current Time'; > +------------------------+ > | Formatted Current Time | > +------------------------+ > | August 29, 2001 | > +------------------------+ > 1 row in set (0.00 sec) > > OR..... [this ex: assumes you have the connection string established] > > $strSQL = "SELECT DATE_FORMAT(NOW(), '%M %d, %Y') 'Formatted Current > Time'"; > $results = mysql_query($strSQL, $db) or die("Cannot execute $strSQL"); > > list($formattedDate) = mysql_fetch_array($results); > > and you're done! > > HTH, > > Christopher Oson > > -----Original Message----- > From: Jeff Oien [mailto:jeff@webdesigns1.com] > Sent: Wednesday, August 29, 2001 8:29 PM > To: PHP-DB > Subject: RE: [PHP-DB] Date_Format Question > > > Isn't that what I tried? > Jeff Oien > > > Although it might be better to format the date in php, don't forget you > can > > also do date formating in the select string. The date format functions > for > > mySQL can me found here: > > > > http://www.mysql.com/doc/D/a/Date_and_time_functions.html > > > > Hope this helps, > > > > > > > > -----Original Message----- > > From: Jeff Oien [mailto:jeff@webdesigns1.com] > > Sent: Wednesday, August 29, 2001 8:07 PM > > To: PHP-DB > > Subject: [PHP-DB] Date_Format Question > > > > > > I have a date like this in date format in MySQL > > 2001-08-29 > > > > and I want it to say > > August 29, 2001 > > > > I tried this and it didn't work. > > select date_format('creation_date', '%b %D, %Y') from Chart_Users; > > > > Could you tell me what I'm doing wrong or how I should do this? Thanks. > > Jeff Oien > > > > -- > > PHP Database Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > > For additional commands, e-mail: php-db-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > > -- > PHP Database Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > >

« previous php.db (#11994) next »