Can any one please let me know, i need to change the data format 2010-05-14 17:53
to 14/05/2010 17:53
using mysql select query
MySQL uses yyyy-mm-dd format for storing a date value. This format is fixed and it is not possible to change it. For example, you may prefer to use mm-dd-yyyy format but you can't. Instead, you follow the standard date format and use the DATE_FORMAT function to format the date the way you want.
Change the curdate() (current date) format in MySQL The current date format is 'YYYY-mm-dd'. To change current date format, you can use date_format().
MySQL retrieves and displays DATE values in ' YYYY-MM-DD ' format. The supported range is '1000-01-01' to '9999-12-31' . The DATETIME type is used for values that contain both date and time parts. MySQL retrieves and displays DATETIME values in ' YYYY-MM-DD hh:mm:ss ' format.
try this select..
SELECT DATE_FORMAT(datefield, "%d/%m/%Y %H:%i") FROM <TableName> WHERE <clause>
select date_format(date_column, "%d/%m/%Y %H:%i") from table_name
Maybe this link might help you MySQL Manuel
This should do the trick :
Select DATE_FORMAT(now(),'%d/%m/%Y %H:%i');
For hour, u can use %H or %h, depending if you want 24h or 12h display. %H will set 24h, %h will set 12h.
Use DATE_FORMAT
to format your DATE. To solve your conversion, use the following code as a pointer
SELECT DATE_FORMAT('2010-05-14 17:53', '%d/%m/%Y %H:%i');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With