简体   繁体   English

有没有办法以 YYYYMMDDHHMMSS 而不是 YYYY-MM-DD HH:MM:SS 的格式在 MySQL 8 中获取 CURRENT_TIMESTAMP?

[英]Is there a way to get CURRENT_TIMESTAMP in MySQL 8 in the format of YYYYMMDDHHMMSS instead of YYYY-MM-DD HH:MM:SS?

Is there a way to get CURRENT_TIMESTAMP in MySQL 8 in the format of YYYYMMDDHHMMSS instead of YYYY-MM-DD HH:MM:SS?有没有办法以 YYYYMMDDHHMMSS 而不是 YYYY-MM-DD HH:MM:SS 的格式在 MySQL 8 中获取CURRENT_TIMESTAMP

SELECT CURRENT_TIMESTAMP; is returning 2021-04-20 15:33:11 currently.目前正在返回2021-04-20 15:33:11

yes, using DATE_FORMAT function是的,使用DATE_FORMAT function

select DATE_FORMAT(CURRENT_TIMESTAMP, '%Y%m%d%H%i%s')

output: output:

20210420154359 20210420154359

Use numeric context:使用数字上下文:

SELECT 0 + CURRENT_TIMESTAMP;

MySQL 8.0 Reference Manual /... / Date and Time Literals MySQL 8.0 参考手册 /... / 日期和时间文字

暂无
暂无

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

相关问题 在MySQL中将间隔格式设置为'yyyy-mm-dd hh:MM:ss' - Formatting an interval as 'yyyy-mm-dd hh:MM:ss' in MySQL 如何将mili第二种格式更改为yyyy-mm-dd hh:mm:ss以插入到具有datetype colunm的mysql中 - How to change mili second format to yyyy-mm-dd hh:mm:ss to insert to mysql with datetype colunm YYYY-MM-DD HH:MM:SS[.fraction] 格式的 MySQL 更新日期字段 - MySQL update date field in YYYY-MM-DD HH:MM:SS[.fraction] format 将MYSQL日期时间值转换为UTC时区格式yyyy-MM-dd'T'HH:mm:ss'Z' - convert MYSQL datetime value to UTC Timezone format yyyy-MM-dd'T'HH:mm:ss'Z' 将YYYY-MM-DD HH:MM:SS格式的java.util.Date转换为与MySQL DATETIME兼容 - Convert java.util.Date in YYYY-MM-DD HH:MM:SS format to compatible with MySQL DATETIME 如何在MySQL中导入Excel存储的数据并保持日期格式为yyyy-mm-dd hh:mm:ss - How to import excel stored data in MySQL and keep date format as yyyy-mm-dd hh:mm:ss 如何从时间yyyy-mm-dd减去hh:mm时间戳hh:mm:ss时间戳 - How to Minus hh:mm time stamp from the Time yyyy-mm-dd hh:mm:ss timestamp 将DD / MM / YYYY HH:MM:SS转换为MySQL TIMESTAMP - Convert DD/MM/YYYY HH:MM:SS into MySQL TIMESTAMP MM-YYYY 到 YYYY-MM-DD hh:mm:ss 在 php 和 mysql - MM-YYYY to YYYY-MM-DD hh:mm:ss on php and mysql 如何在VBA中以“ yyyy / MM / dd hh:mm:ss.fff”格式获取时间戳? - How can I get the timestamp in “yyyy/MM/dd hh:mm:ss.fff"” format in VBA?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM