MySQL Forums
Forum List  »  Newbie

Re: Converting date to string
Posted by: Jay Alverson
Date: February 13, 2009 09:15PM

This should get you started...

Download the MySQL Manual for your version at:
http://dev.mysql.com/doc/#refman

lookup the date & time functions in the INDEX...

mysql> select * from mydates;
+------+------------+
| name | real_date  |
+------+------------+
| aaa  | 2009-02-04 |
| bbb  | 2009-02-04 |
| ccc  | 2009-02-05 |
| ccc  | 2009-02-06 |
| ccc  | 2009-02-07 |
| ccc  | 2009-02-08 |
| ccc  | 2009-02-09 |
| ccc  | 2009-02-10 |
| ccc  | 2009-02-11 |
+------+------------+
9 rows in set (0.00 sec)

mysql> select real_date, concat(monthname(real_date), " ", day(real_date), " ",
year(real_date)) as "Date as String" from mydates;
+------------+------------------+
| real_date  | Date as String   |
+------------+------------------+
| 2009-02-04 | February 4 2009  |
| 2009-02-04 | February 4 2009  |
| 2009-02-05 | February 5 2009  |
| 2009-02-06 | February 6 2009  |
| 2009-02-07 | February 7 2009  |
| 2009-02-08 | February 8 2009  |
| 2009-02-09 | February 9 2009  |
| 2009-02-10 | February 10 2009 |
| 2009-02-11 | February 11 2009 |
+------------+------------------+
9 rows in set (0.00 sec)

mysql>

>

Thanks, Jay



Edited 1 time(s). Last edit at 02/13/2009 09:16PM by Jay Alverson.

Options: ReplyQuote


Subject
Written By
Posted
February 13, 2009 03:37PM
February 13, 2009 03:56PM
Re: Converting date to string
February 13, 2009 09:15PM
February 13, 2009 09:51PM
February 14, 2009 02:02AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.