MySQL Now() 与 GetDate()

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20964578/
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 19:46:56  来源:igfitidea点击:

Now() vs GetDate()

mysqlsqlsql-server

提问by SMK

I am migrating my database from sqlserver to mysql when i come to getDate()function in sqlserver the replacement in mysql is Now()but Now()not returned the exact result and format that getDate()returned.

当我getDate()在 sqlserver 中运行时,我正在将我的数据库从 sqlserver 迁移到 mysql,mysql中的替换是Now()Now()没有返回确切的结果和返回的格式getDate()

Is there any solution to tweak the Now()result to make as same as getDate()

是否有任何解决方案可以调整Now()结果以使其与getDate()

getDate() result : 2014-01-07 00:28:46.017

Now() result     : 2014-01-07 10:28:03

回答by SMK

I overcome the problem of microsecond by usage of

我通过使用克服了微秒的问题

    sysdate(3) returned '2014-01-07 10:52:07.252'

Thanks for every one suggestions.

谢谢你的每一个建议。

回答by Vignesh Kumar A

The difference between the two functions is the milliseconds. Try converting the getdate() to exclude milliseconds.

这两个函数之间的区别是毫秒。尝试转换 getdate() 以排除毫秒。

回答by Szymon

The formatis different but the values are the same. You should format the values according to your needs but as for storage, they should be stored in the binary format (e.g. using DATETIMEdata type).

格式是不同的,但值是相同的。您应该根据需要格式化这些值,但至于存储,它们应该以二进制格式存储(例如使用DATETIME数据类型)。