CSV files are not formatted; they simply contain data.
MS Excel will review this data and try to set the appropriate format for it. For example, this means the correct numeric value. It can recognize a string containing a human-readable date / time value and convert it to its own timestammp value (represented as a floating point number), and then apply the corresponding corresponding date / time mask to this cell, so that it is erased as a date or time, but it’s not necessary to use the string representation that you had in your CSV file.
Solution # 1, prefix your formatted date string with the = character and wrap it in quotation marks so that it is treated as a string.
Solution No. 2, write the actual Excel file in which you can control the formatting of the cells.
source share