Go4Expert

Go4Expert (http://www.go4expert.com/)
-   PHP (http://www.go4expert.com/forums/php/)
-   -   Date format in MySQL (http://www.go4expert.com/forums/date-format-mysql-t422/)

Mike 22Aug2005 22:19

Date format in MySQL
 
In mySql DB date is stored as a yyyy-mm-dd but i want to show it as dd-mm-yyyy.

shabbir 23Aug2005 08:28

Re: Date format in MySQL
 
Use of SQL's prime reason is whatever you store is independent of what you can retrieve (format). That is view can be changed to whaterver format we wish to get from the stored data.

Now when you store the date its like yyyy-mm-dd and now to retrieve in dd-mm-yyyy you can just use the following SQL so that you dont need to do anything fancy in PHP

PHP Code:

$sql "SELECT DATE_FORMAT(date_column_name, '%d-%m-%Y') AS new_date FROM table_name WHERE...."

Also you can see the complete Description of DATE_FORMAT function here http://dev.mysql.com/doc/mysql/en/da...functions.html

Mike 27Aug2005 15:28

Re: Date format in MySQL
 
Thaks

Mike 27Aug2005 15:28

Re: Date format in MySQL
 
OOPs Type error. Thanks.


All times are GMT +5.5. The time now is 09:42.