简体   繁体   English

从MySQL到Excel的CSV导入在日期结束时保留“ /”

[英]CSV Import to Excel from MySQL leaves “/” at end of dates

After exporting my sql query to a csv file, more specifically the "CSV for Excel" format from phpMyAdmin, the dates are properly saved in quotes. 将我的sql查询导出到csv文件后,更具体地说是从phpMyAdmin导出为“ CSV for Excel”格式后,日期将正确保存在引号中。 Ex: "1990-01-30" . 例如: "1990-01-30" The delimiter is ; 分隔符为; . However, when I import the file to Excel, all the dates, except the last date last record, end in a "/". 但是,当我将文件导入Excel时,除最后一个记录的最后日期以外的所有日期都以“ /”结尾。

MySQL Date: 1990-01-30 MySQL日期: 1990-01-30

Import to Excel via csv 通过CSV导入到Excel

Excel Date: 1990-01-30/ Excel日期: 1990-01-30/

Last Date Last Record: 1952-12-24} (Note the }) Last Date Last Record: 1952-12-24} (请注意})

How do I fix this without manually fixing each date? 如何解决此问题而无需手动确定每个日期?

This will strip the last character off the text, and turn it into a date value 这将从文本中去除最后一个字符,并将其转换为日期值

=DATEVALUE(LEFT(A1,LEN(A1)-1))
  • DateValue returns the value in excel's usual number format - format the cells as a date to see the dates DateValue以excel常用的数字格式返回值-将单元格格式化为日期以查看日期
  • The last date will still work, as the formula does not care what the extra character is 最后一个日期仍然有效,因为公式并不关心多余的字符是什么

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM