简体   繁体   中英

Setting a date variable in mysql

Why does the following return a MEDIUMTEXT type?

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?

You should probably be using single quotes for MySQL date literals:

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

Double quotes indicate database objects. Note that you don't need the ANSI date keyword here.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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