MySQL date formats - difficulty Inserting a date

后端 未结 5 1430
名媛妹妹
名媛妹妹 2020-12-23 19:39

I am trying to further a question I asked yesterday where I wanted to know how to query a date in a different format. But now I am trying to do an insert using this method (

5条回答
  •  -上瘾入骨i
    2020-12-23 20:22

    An add-on to the previous answers since I came across this concern:

    If you really want to insert something like 24-May-2005 to your DATE column, you could do something like this:

    INSERT INTO someTable(Empid,Date_Joined)
    VALUES
        ('S710',STR_TO_DATE('24-May-2005', '%d-%M-%Y'));
    

    In the above query please note that if it's May(ie: the month in letters) the format should be %M.

    NOTE: I tried this with the latest MySQL version 8.0 and it works!

提交回复
热议问题