mysql 至少有2个年龄大于40岁,在MySQL中计算年龄时出错?
I am trying to calculate age with the SQL statement below
round(datediff(now() - dateofbirth / 365))
gives the following error,
1582 - Incorrect parameter count in the call to native function 'datediff'
解決方案
Problem : datediff expects two parameters like DATEDIFF(expr1,expr2) , as per the given question, there is only one parameter hence error.
Solution : you have to use,
round(datediff(now() , (dateofbirth / 365)))
^
the datediff returns expression1 – expression2, so you dont have to do it by yourself :) also make sure the parameters are date or date-and-time expressions
EDIT : Another error pointed out by @Jonathan Leffler,division is needed after the call to DATEDIFF.
round(datediff(now(),dateofbirth)/365)
總結(jié)
以上是生活随笔為你收集整理的mysql 至少有2个年龄大于40岁,在MySQL中计算年龄时出错?的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: java调用spark_spark中的并
- 下一篇: java抽象工厂模式_Java 抽象工厂