To change the data type of the storage time in the database to varchar (), it is best to make these times automatically generated in the database (an unformatted input may also result in an output error), because the storage type is varchar (), so the obtained value is considered a string. Convert the time strings in the database directly (at which point the conversion functions are able to recognize the time functions in the database), and the client's time format no longer affects the conversion process.
However, the type of storage time in a database can be problematic if it is a character type:
The time in the database is only used to display, find, then the impact is not big, but if the time field to do some algorithms such as computing weeks, DateDiff, DateAdd, and so on, it is troublesome, especially the large data query conversion type is the impact of efficiency
Summarize
Should the field type of the date stored in the database be either varchar or datetime? Both methods have advantages, and datetime can borrow the arithmetic functions in the SQL function library to increase the efficiency of time on various operations, while the varchar type can show advantages in character coding. You might consider choosing a varchar type if the stored time does not require a large amount of computation in the future, and conversely, choosing a datetime type.
Whether the field type of the date stored in the database should be either varchar or datetime