how to format date field in MYSQL

前端 未结 5 1878
粉色の甜心
粉色の甜心 2021-01-25 07:13

All,

I need to retrieve the date in some specific format in MYSQL. For eg,

it should return month/year(10/2009).

My MYSQL version is 5.1.

Thanks

相关标签:
5条回答
  • 2021-01-25 07:36

    Check the documentation for this function in MySQL

    DATE_FORMAT(date, format)

    DATE_FORMAT(col, '%m/%Y')
    
    0 讨论(0)
  • 2021-01-25 07:46

    DATE_FORMAT function

    DATE_FORMAT(col,'%m/%Y')
    
    0 讨论(0)
  • 2021-01-25 07:48
    date_format(yourdatefield, '%c/%Y') as formatted_date
    

    will do that- http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_date-format

    0 讨论(0)
  • 2021-01-25 07:58

    use DATE_FORMAT function

    http://www.mysqlformatdate.com will help you use the function properly

    0 讨论(0)
  • 2021-01-25 08:00

    For IIS, I just use a function:

    FUNCTION mySLQDate(xdate)
        IF xdate <> "" THEN
            mySLQDate = year(xdate) & "/" & month(xdate) & "/" & day(xdate)
        END IF
    END FUNCTION
    
    0 讨论(0)
提交回复
热议问题