I have a column CreatedDate and I want to set the below default value in the below format for this column.
Default value:- yyyy-mm-dd 00:00:00.000
I have tried multiple solutions like I have used DATETIME datatype, TIMESTAMP but it is not taking the default value.
Could someone please share your thoughts on this?
Thanks,
2
Answers
The format you show is the default datetime format if you define the column with millisecond precision.
Demo:
There is no way to change the default format of a datetime. Datetimes are not stored as a string, they are stored as a binary value. You must use the DATE_FORMAT() function to display a different format.
If you just want to set the default value to a specific hard-coded value, you can use the following
See ALTER TABLE Statement docs