sql working days holidays

前端 未结 3 670
攒了一身酷
攒了一身酷 2021-01-16 10:07

I\'ve seen different version of this kind of function for other coding languages (Python, jQuery, etc.) but not for SQL. I have a procedure that needs to have a date calcul

3条回答
  •  深忆病人
    2021-01-16 10:52

    I've always achieved this with a static table of dates from roughly 5 years in the past to 10 in the future, each date being marked with 'working day' status and sometimes other flags as required. Previously using MS-SL server I would achieve this quickly with a WHILE loop, I think MySQL supports the same syntax

    WHILE (condition)
    BEGIN
     INSERT date
    END
    

    To create the table either use the Enterprise Manager UI or something like

    CREATE TABLE DateTable
     (
       actual_date datetime NOT NULL,
       is_holiday bit NOT NULL
     )
    

提交回复
热议问题