我尝试将这些mysql函数用于波斯日期我得到了这个错误但我无法解决它
SQL query:
CREATE FUNCTION `persian_day` (
indate date
) RETURNS int( 11 ) BEGIN declare j int;
MySQL said: Documentation
#1064 - You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near '' at line 3
我使用 mysqlnd 5.0.8-dev 和 phpmyadmin(xampp 包)
这是我的功能
CREATE FUNCTION `persian_mod`(a double,b double) RETURNS int(11)
return (a - b * floor(a / b))
CREATE FUNCTION `persian_div`(a double,b double) RETURNS int(11)
return (floor(a / b))
CREATE FUNCTION `persian_pj`(y int,m int,d int) RETURNS int(11)
return ( 227260 +
1029983 * persian_div((y - 474), 2820) +
365 * ( (persian_mod((y - 474), 2820) + 474) - 1) +
persian_div(682 * (persian_mod((y - 474), 2820) + 474) - 110, 2816) +
if(m > 6, 30 * m + 6, 31 * m)
+ d )
CREATE FUNCTION `persian_day`(indate date) RETURNS int(11)
begin
declare j int;
declare a int;
declare b int ;
declare c int;
declare d int;
declare yearr int;
declare f double;
declare monthh int;
set j=TO_DAYS(indate) ;
set a = j - persian_pj(475, 0, 1) ;
set b = persian_div(a, 1029983) ;
set c = persian_mod(a, 1029983) ;
set d = if(c <> 1029982, persian_div(2816 * c + 1031337, 1028522), 2820) ;
set yearr = 474 + 2820 * b + d;
set f = (1 + j) - persian_pj(yearr, 0, 1);
set monthh= if(f > 186, ceil((f - 6) / 30) - 1, ceil(f / 31) - 1);
return (j - (persian_pj(yearr, monthh, 1) - 1));
end
为什么会发生此错误?以及如何解决?