MySQL:Curdate() 与 Now()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/4397755/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-31 17:56:34  来源:igfitidea点击:

MySQL: Curdate() vs Now()

mysqlsqldatetime

提问by Pekka

What is difference between MySQL Curdate()and Now()?

MySQLCurdate()和 有什么区别Now()

回答by Pekka

For questions like this, it is always worth taking a look in the manual first. Date and time functions in the mySQL manual

对于这样的问题,总是值得先看一下手册。mySQL 手册中的日期和时间函数

CURDATE()returns the DATE part of the current time. Manual on CURDATE()

CURDATE()返回当前时间的 DATE 部分。CURDATE() 手册

NOW()returns the date and time portions as a timestamp in various formats, depending on how it was requested. Manual on NOW().

NOW()根据请求的方式,以各种格式将日期和时间部分作为时间戳返回。NOW() 手册

回答by Jonathan Joosten

Just for the fun of it:

就是图个好玩儿:

CURDATE() = DATE(NOW())

Or

或者

NOW() = CONCAT(CURDATE(), ' ', CURTIME())

回答by Sanjay Khatri

CURDATE()will give current date while NOW()will give full date time.

CURDATE()将给出当前日期,而NOW()将给出完整的日期时间。

Run the queries, and you will find out whats the difference between them.

运行查询,您将发现它们之间的区别。

SELECT NOW();     -- You will get 2010-12-09 17:10:18
SELECT CURDATE(); -- You will get 2010-12-09

回答by Sonpal singh Sengar

Actually MySQL provide a lot of easy to use function in daily life without more effort from user side-

实际上 MySQL 在日常生活中提供了很多易于使用的功能,而无需用户方面的更多努力-

NOW()it produce date and time both in current scenario whereas CURDATE()produce date only, CURTIME()display time only, we can use one of them according to our need with CASTor merge other calculation it, MySQL rich in these type of function.

NOW()它在当前场景中产生日期和时间,而 CURDATE()只产生日期,CURTIME()只显示时间,我们可以根据需要使用其中之一与CAST或合并其他计算它,MySQL 丰富这些类型的功能。

NOTE:-You can see the difference using query select NOW() as NOWDATETIME, CURDATE() as NOWDATE, CURTIME() as NOWTIME ;

注意:-您可以使用查询 select NOW() as NOWDATETIME, CURDATE() as NOWDATE, CURTIME() as NOWTIME 来查看差异;