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

  • SEARCH
  • Home
  • 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 8821325
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T05:49:30+00:00 2026-06-14T05:49:30+00:00

I am getting a syntax error with this due to the final while loop.

  • 0

I am getting a syntax error with this due to the final while loop. I have tried switching it around but cant find the issue here – is it purely that MySQL doesn’t support if statements within while loops?

DELIMITER //
CREATE PROCEDURE bLAHbLAHbLAH(p_fromdate datetime, p_todate datetime)
BEGIN

Declare startday datetime;
declare numberofdays int;
declare Counter int;

Set startday = p_fromdate;
Set numberofdays = (select datediff("2012-05-01","2012-11-01"));
Set Counter = 0;

WHILE startday<p_todate DO
    if (select date_format(startday, '%W')) in ('Monday','Tuesday','Wednesday','Thursday','Friday') THEN
        SET Counter = Counter+1;
        SET startday = date_add(startday, INTERVAL 1 DAY);
    else
        SET startday = date_add(startday, INTERVAL 1 DAY);
END WHILE;

select Counter; 

END//

DELIMITER ;
  • 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-14T05:49:32+00:00Added an answer on June 14, 2026 at 5:49 am

    You forgot an

    end if;
    

    before the end while

    WHILE startday<p_todate DO
        if (select date_format(startday, '%W')) in ('Monday','Tuesday','Wednesday','Thursday','Friday') THEN
            SET Counter = Counter+1;
            SET startday = date_add(startday, INTERVAL 1 DAY);
        else
            SET startday = date_add(startday, INTERVAL 1 DAY);
        end if;                                                   /*add this line*/
    END WHILE;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm getting a syntax error with this access query, but I can't see what
i am using this code <a onclick=javascript:var t=setInterval(GetUpdates(5,ajaxResult),300);>GetUpdates</a> but getting the syntax error
Im referencing the PHP manual but Im getting a syntax error due to the
I'm getting this syntax error and I know it's PHP 101, but I wouldn't
I'm getting a syntax error on this query, but I can't figure it out.
I have written this SQLite statement and I am getting syntax error on the
i'm getting this error: Parse error: syntax error, unexpected T_PRINT, expecting T_STRING in /homepages/26/d94605010/htdocs/lz/writecodeonline.com/php/index.php(190)
I'm getting a strange syntax error when I run this in VB: SQLString =
I'm getting this error whenever I attempt to declare a class: Parse error: syntax
I am getting an error Incorrect syntax near ',' for this query on line

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.