Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8379995
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T16:20:28+00:00 2026-06-09T16:20:28+00:00

i tried to use these mysql function for persian date i got this error

  • 0

i tried to use these mysql function for persian date
i got this error but i couldnt solve it

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 

i use mysqlnd 5.0.8-dev with phpmyadmin (xampp package)

here is my function

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

why this error happen?and how to solve it?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-09T16:20:30+00:00Added an answer on June 9, 2026 at 4:20 pm

    The basic syntax when creating a function is that you should have a return statement.

    CREATE FUNCTION fnctionName (paramList)
    RETURNS datatype
    BEGIN
       RETURN valueToReturn;
    END
    

    but if you have special calculation (of course it’s multiline) inside your function, you need to change the delimiter first:

    DELIMITER $$
    CREATE FUNCTION fnctionName (paramList)
    RETURNS datatype
    BEGIN
       DECLARE ....;
    
       ..... other codes ;
    
       RETURN valueToReturn;
    END $$
    DELIMITER ;
    

    back in your case,

    CREATE FUNCTION `persian_day` (indate date) RETURNS int( 11 ) 
    BEGIN 
         declare j int;
    

    you have not RETURN value and you haven’t close the function using END keyword. Just like what you did on the other functions you have created.

    CREATE FUNCTION Example

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I tried to use object expression to extend the IDelegateEvent, but in fsi there
I tried to use the following function in order to set the div's position
I tried to use Hibernate Envers to log the entity histroy. but failed. My
I tried to use this snippet from the Soundcloud API: <script src=http://connect.soundcloud.com/sdk.js> <script> SC.initialize({
I normally use this function to sanitize my form inputs before storing them into
original question: <select> dropdown output my MYSQL data properly using JS function I tried
I have a problem incorporating a Group_Concat function in my SQL query. I have
My mamp mysql server won't turn on. I tried executing /Applications/MAMP/bin/startMysql.sh but that gave
I have recently tried to use the php mail function to send out confirmation
I'm writing a function that queries my database, and if the mysql query errors

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.