gpt4 book ai didi

mysql - mysql 出现超出范围错误

转载 作者:行者123 更新时间:2023-11-29 14:08:41 25 4
gpt4 key购买 nike

我试图使用mysql实现黑客新闻算法并得到以下错误

    Double value is out of range in 
pow(((unix_timestamp() - unix_timestamp(postDateTime))/3600 + 1),1.5)

Where the value of postDateTime is 2012-12-15 10:41:31

如果我将上述实现为

pow(((unix_timestamp() - unix_timestamp(cast(postDateTime as signed)))/3600 + 1),1.5)

它工作完美,但我不明白其背后的原因

最佳答案

您运行的 mysql 版本是什么?检查this link出来。

并检查the documentation了解为什么您会得到负值:

If called with no argument, returns a Unix timestamp (seconds since '1970-01-01 00:00:00' UTC) as an unsigned integer. If UNIX_TIMESTAMP() is called with a date argument, it returns the value of the argument as seconds since '1970-01-01 00:00:00' UTC. date may be a DATE string, a DATETIME string, a TIMESTAMP, or a number in the format YYMMDD or YYYYMMDD. The server interprets date as a value in the current time zone and converts it to an internal value in UTC.

...

If you want to subtract UNIX_TIMESTAMP() columns, you might want to cast the result to signed integers. See Section 12.10, “Cast Functions and Operators”.

关于mysql - mysql 出现超出范围错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13891809/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com