【发布时间】:2023-04-10 15:09:01
【问题描述】:
我目前正在尝试从多个日期列中删除时间戳。实际上,select 语句中的大多数列都包含日期。我想从查询结果中的所有日期值中删除时间戳。这可以在 MySQL 中完成吗?
select Date(column1, column2, column3...) FROM ... 似乎不起作用。 选择 DATE (column1), DATE(column2), DATE(column3).... 似乎也不起作用
SELECT
col1,
col2,
col3, //this is a date field
col4 //this is a date field
FROM table1
UNION
SELECT
col1,
col2, //this is a date field
col3, //this is a date field
col4 //this is a date field
FROM table2
所有日期值不应包含时间戳
【问题讨论】:
-
您查看过
date() function吗?你会使用date(col3), date(col4) -
使用
DATE()应该在这里工作。怎么不行? -
@TimBiegeleisen date(col1), date(col2) 格式确实有效,但“date(col1)”现在成为导出中的列标题,这不是首选。