• CELKO (9/27/2010)


    Alexander Kuznetsov (9/24/2010)


    CELKO (9/23/2010)


    I still prefer Julianizing the business days to make the math easier

    CREATE TABLE Calendar

    (cal_date DATE NOT NUL PRIMARY KEY,

    julian_business_nbr INTEGER NOT NULL,

    ...);

    INSERT INTO Calendar

    VALUES ('2007-04-05', 42),

    ('2007-04-06', 43), -- good friday

    ('2007-04-07', 43),

    ('2007-04-08', 43), -- Easter sunday

    ('2007-04-09', 44),

    ('2007-04-10', 45); --Tuesday

    To compute the business days from Thursday of this week to next

    Tuesday:

    SELECT (C2. julian_business_nbr - C1. julian_business_nbr)

    FROM Calendar AS C1, Calendar AS C2

    WHERE C1.cal_date = '2007-04-05',

    AND C2cal_date = '2007-04-10';

    Yes, we do it too. When a new holiday comes up, like President Ford's funeral, we update all those future numbers.

    The updating is not much of a problem:

    1) New holidays do not occur very often, per one or two per decade at most. But queries about business days occur very frequently.

    Joe,

    In general, I concur - storing consecutive numbers with business days makes perfect sense. Yet changes in what is a business day occur all the time, especially if we deal with multiple countries, and a business day must be such in all involved countries. Even if we limit the scope to US only, changes do occur. Just recently, Chicago Mercantile Exchange announced how they are going to operate on Columbus Day, and that seems to e a change from previous years.