当前位置:网站首页>mysql导入导出数据到excel表日期出现问题
mysql导入导出数据到excel表日期出现问题
2022-06-25 12:16:00 【王会举】
1:问题描述
今天我在导出sql数据的时候,发现导出excel的日期竟然不对.数据库中的列是 datetime格式, 但是导出到excel后日期变成了日月年.
数据库中的日期
导出到excel后的日期 
这种问题导致了导入也会报错
2:解决方案
网上有人说 在excel上修改单元格的格式为日期就行了. 但是我用的wps,修改单元格格式实际并没有任何作用,
我的解决方案,在获取结果集的时候,就将日期的列,转换为字符串.然后再导出.使用DATE_FORMAT 这个函数
select DATE_FORMAT(你的日期列名,'%Y-%m-%d %H:%i:%s') from 你的表名
就成功的解决了导出日期混乱的问题.
格式化后的输出
3:DATE_FORMAT 相关介绍
DATE_FORMAT(参数1,参数2 ) 有两个参数, 参数1是你的日期列名, 参数2是输出的格式化规则
- %Y 年,四位数字
- %y 年,后两位数字
- %m 月 ,数字[1-12]
- %d 日,月份里的第几天,两位数字[1-31]
- %H 小时,24进制 [0-23]
- %h 小时,12进制[0-11]
- %i 分钟 [0-59]
- %s | %S 秒 0-59
边栏推荐
- The difference between this and super and their respective functions
- Slice() and slice() methods of arrays in JS
- Common software numerical filtering methods (I) have been applied
- How to implement a high-performance load balancing architecture?
- 20220620 interview reply
- flutter 收到推送后自动消失问题
- Select randomly by weight [prefix and + dichotomy + random target]
- (5) Pyqt5 ---- another method of connecting signals and slots
- Foreach method of array in JS
- Another night when visdom crashed
猜你喜欢

为何数据库也云原生了?

High performance + million level Excel data import and export

架构师需要具备的能力

地理空间搜索 ->R树索引

The amount is verified, and two zeros are spliced by integers during echo

mysql FIND_ IN_ Set function

How to implement a high-performance load balancing architecture?

架构师必备的七种能力

利用cmd(命令提示符)安装mysql&&配置环境

画图常用配色
随机推荐
Event triggered when El select Clear clears content
QT TCP UDP network communication < theory >
Singleton mode in PHP to reduce memory consumption
Oracle trigger error report table or view does not exist
英语口语 - 弱读
Resolved: could not find artifact XXX
visual studio2019链接opencv
Select randomly by weight [prefix and + dichotomy + random target]
最大数[抽象排序之抽象规则]
Update PIP & Download jupyter Lab
JS array de duplication
Negative sample image used in yolov5 training
GPS NMEA protocol, 0183 positioning data format dual mode positioning: gnxxx gps+bd full version
Connect with the flight book and obtain the user information according to the userid
百度搜索稳定性问题分析的故事
Baidu search stability analysis story
It is extraordinary to make a move, which is very Oracle!
Spoken English - weak reading
顺序表的折半查找法
My first experience of go+ language -- a collection of notes on learning go+ design architecture