0

I tried fetching date from table using date(column_name) which gives output:

2018-03-13

But is there a way to get the same result in the format

2018, 03, 13
Salman A
  • 262,204
  • 82
  • 430
  • 521
Atul Stha
  • 1,404
  • 8
  • 23
  • 46

3 Answers3

5

You Can Use

SELECT REPLACE(col_Name,'-',', ') FROM table_Name;

Or

SELECT DATE_FORMAT(col_Name, '%Y, %m, %d') FROM table_Name;  

Example

SELECT REPLACE('2018-03-13','-',', ')

Output

2018, 03, 13

Live Demo

http://sqlfiddle.com/#!9/e80e77/6

Jay Shankar Gupta
  • 5,918
  • 1
  • 10
  • 27
4

Use DATE_FORMAT method provided by mysql.

SELECT DATE_FORMAT("2018-03-13", "%Y, %m, %d");

Result:

2018, 03, 13
Farhan Tahir
  • 2,096
  • 1
  • 14
  • 27
2

There is.

SELECT DATE_FORMAT("2018-03-13", "%Y, %m, %d");  

Source: https://www.w3schools.com/sql/func_mysql_date_format.asp

R4LPH
  • 41
  • 10