Creating Days in a Year - Stored Procedure

[email protected] (Pointmade_Noah1)
Newsgroups php.general
Message-ID <[email protected]>
I found this code below online and I am trying to modify it for my  
needs. I want to pass a YEAR (Int) to the stored procedure and have it  
create all the day in that passed year. With one tweak, If the day is  
Sunday the "sStatus" field will equal "Closed" ELSE "Open". All  
attempts come up with ERRORS. Also, I would like the sdate field to be  
a DATE result.  Little help please? I appreciate it.

USE colombo;

-- this table will store dates sequence 
CREATE TABLE seq_dates
(
    sdate DATETIME NOT NULL,
    sStatus VARCHAR NULL,
);

DROP PROCEDURE IF EXISTS colombo.sp_init_dates;

CREATE PROCEDURE colombo.sp_init_dates
(IN p_fdate DATETIME, IN p_tdate DATETIME)
BEGIN
DECLARE v_thedate DATETIME;
DECLARE v_Status VARCHAR;

TRUNCATE TABLE colombo.seq_dates;

SET v_thedate = p_fdate;

WHILE (v_thedate < p_tdate) DO

IF (DayName(v_theDate) = "Sunday" {
SET v_Status = "Closed";
}else{
SET v_Status = "Open";
}  // I know this CODE is wrong

    -- insert dates squence into seq_dates table
    INSERT INTO seq_dates (sdate, sStatus)
    VALUES (v_thedate, v_Status);

    -- go to the next day
    SET v_thedate = DATE_ADD(v_thedate, INTERVAL 1 DAY);

END WHILE;

END;
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.