Nisar
Nisar

Reputation: 6038

Convert datetime to varchar from MSSQL to MYSQL

how to convert this line of MSSQL to MYSQL

SELECT convert(VARCHAR(10), getdate(),106) -- dd mm yyyy

I have no idea how to do it in mysql please help..

Upvotes: 0

Views: 2776

Answers (3)

웃웃웃웃웃
웃웃웃웃웃

Reputation: 11984

You can use DATE_FORMAT for the formatting of date in mysql

select DATE_FORMAT(now(),'%d-%m-%Y') as curr_date

Upvotes: 2

Scary Wombat
Scary Wombat

Reputation: 44824

You can use the DATE_FORMAT function of MYSQL

See http://dev.mysql.com/doc/refman/5.6/en/date-and-time-functions.html#function_date-format

mysql> SELECT DATE_FORMAT('2009-10-04 22:23:00', '%W %M %Y');
    -> 'Sunday October 2009'

or in your case

mysql> select DATE_FORMAT(now(),'%d-%m-%Y');

Upvotes: 1

Erez A. Korn
Erez A. Korn

Reputation: 2758

I couldn't be sure if this is what you wanted from the question, but you may be able to use this as a possible guideline.

SELECT DATE_FORMAT(NOW(), '%d %m %Y') AS date_variable_name;

Upvotes: 2

Related Questions