简体   繁体   English

SQL NOW()函数无法正常工作

[英]SQL NOW() function not working properly

I'm trying to insert the date in aa query, using the NOW() statement. 我正在尝试使用NOW()语句在日期中插入日期。

However only the Ymd are being inserted correctly, while the hours, minutes and seconds are all appearing zeros ( 00:00:00 ) 但是只有正确插入Ymd,而小时,分钟和秒都显示为零(00:00:00)

Any reason for that? 有什么理由吗?

Did you check the type of the column you are inserting into? 您是否检查了要插入的列的类型? Make sure it's datetime , not just date . 确保它是datetime ,而不仅仅是date

Refer to the docs for more info. 有关详细信息,请参阅文档

Try this : 尝试这个 :

SELECT CURRENT_TIMESTAMP
or 要么
SELECT GETDATE()
or 要么
Select {fn NOW()}

Note the accolades in the function. 请注意功能中的荣誉。

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

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