问题
The below works for displaying the date, but when writing to the database [in a datetime column] it seems to be getting converted to the default format.
REPLACE(CONVERT(VARCHAR(11),CONVERT(DATETIME,DATE_FIELD),106),' ','-')
回答1:
Date/time values in the database are stored in a binary format. They are not stored as strings. This is the right way to store them.
If you want to fetch the data in a particular format, then use the formula when you retrieve them. Or, you can add a computed column:
alter table t
add date_field_ddmonyyyy as (REPLACE(CONVERT(VARCHAR(11), CONVERT(DATETIME,DATE_FIELD), 106), ' ', '-'));
来源:https://stackoverflow.com/questions/40033754/how-to-store-date-in-dd-mon-yyyy-format-in-sql-server