Best timestamp format for CSV/Excel?

前端 未结 11 2211
盖世英雄少女心
盖世英雄少女心 2020-12-07 16:57

I\'m writing a CSV file. I need to write timestamps that are accurate at least to the second, and preferably to the millisecond. What\'s the best format for timestamps in

11条回答
  •  遥遥无期
    2020-12-07 17:42

    "yyyy-mm-dd hh:mm:ss.000" format does not work in all locales. For some (at least Danish) "yyyy-mm-dd hh:mm:ss,000" will work better.

    as replied by user662894.

    I want to add: Don't try to get the microseconds from, say, SQL Server's datetime2 datatype: Excel can't handle more than 3 fractional seconds (i.e. milliseconds).

    So "yyyy-mm-dd hh:mm:ss.000000" won't work, and when Excel is fed this kind of string (from the CSV file), it will perform rounding rather than truncation.

    This may be fine except when microsecond precision matters, in which case you are better off by NOT triggering an automatic datatype recognition but just keep the string as string...

提交回复
热议问题