简体   繁体   English

在 mysql 中设置日期变量

[英]Setting a date variable in mysql

Why does the following return a MEDIUMTEXT type?为什么以下返回MEDIUMTEXT类型?

set @entered_date = date "2015-01-01";
select @entered_date;

What would be the correct way to store a date in mysql and then later reference that?在 mysql 中存储日期然后再引用它的正确方法是什么?

You should probably be using single quotes for MySQL date literals:您可能应该对 MySQL 日期文字使用单引号:

set @entered_date = '2015-01-01';

Double quotes indicate database objects.双引号表示数据库对象。 Note that you don't need the ANSI date keyword here.请注意,此处不需要 ANSI date关键字。

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

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