• IRRePRESSible (unregistered)

    YES! I did it only took me 27 days

  • ... (unregistered)

    first.

  • Ken Nipper (cs)

    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........

  • maldrich (cs)

    Obviously done for extensibility. If you tie this kind of thing to tenuous structures like DateTime data types or Calendar functions, you'll be sorry when the calendar changes. Just think about all those programmers working when the Gregorian calendar came online. They were spending weeks recoding. Our friend here can just set a few bits and he's all set. You youngsterd think y2k was bad, you just don't remember y1582. Ugly, man. Ugly. Better to roll your own calendar functions than go through THAT again.

  • rob_squared (cs)

    This still doesn't match the amazing power that Microsoft has to reschedule Thanksgiving to fall on a Wednesday:

    http://72.14.203.104/search?q=cache:RzFeU2G46_8J:blogs.msdn.com/jensenh/archive/2005/11/23/496246.aspx+microsoft+bug+thanksgiving+tuesday&hl=en&gl=us&ct=clnk&cd=2

  • Casiotone (cs)

    blnaryHoliday?

    booleanary?

  • marvin_rabbit (cs)
    Alex Papadimoulis:
    +---------+--------------------------------------------------------------------------+
    | intYear | blnaryHoliday                                                            |
    +---------+--------------------------------------------------------------------------+
    |   ...   | ...                                                                      |
    +---------+--------------------------------------------------------------------------+
    |  1995   | NYYYYYNNYYYYYNNYYYYYNNYYYYYNNYYYYYNNYYYYYNNYYYYYNNYYYYYNNYYYYYNNYYYYYNN  |
    +---------+--------------------------------------------------------------------------+

    I also like that in a table tblHoliday, and a field named blnaryHoliday, that the days marked with a "Y" are NOT holidays.  Just another little bundle of joy.
  • Saarus (unregistered)

    This conversation probably happened a couple of years later, after the original developer moved to a new company:

    Original Developer: "Yeah, so I didn't want to have to go through each calendar year and figure out weekends, weekdays, and holidays manually. So I populated this table auto-magically by writing a script to iterate over years from 1975, and figure for each day whether it was a weekend or holiday. Saved me loads of time."

    Rookie: "Why didn't you just... you know... like, adapt the code from that script, instead of... well, instead of storing it in the database like that?"

    Original Developer: "Ah! You are obviously new to enterprise development!"

  • Anon (unregistered)

    Man, I want to work for that company.  You only have to work for 2 days and then you get 5 holidays!!

  • Suck My Lisp (cs) in reply to Ken Nipper

    Because if you used logic instead of Ys and Ns you'd drastically increase the size of your database:

    TRUETRUEFALSEFALSEFALSEFALSEFALSEFALSETRUETRUEFALSE
    FALSEFALSEFALSEFALSETRUETRUE ...


  • Sam (unregistered) in reply to Ken Nipper

    Ken Nipper:
    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........

    I don't think "logic" is the way to go (not sure how you'd logically work out what the holidays would be, anyway -- plus, what happens when that "logic" changes?).  However, you could just put the dates in the table as dates, maybe with a nice little description for the holiday in a separate column.  Plus other column flags like which country it's a holiday for, or whether it's a trading or settlement holiday for finance, or whatever.

    Of course, logic works for weekends.  Is it just me who only sees weekends defined on this chart?

  • Mikademus (cs) in reply to Anon

    That threw me off, why are the non-holidays marked "Y"?!

  • Mihai (unregistered)

    365 bytes, what a waste! Packing it to one bit per day would reduce it to 46 bytes!
    And you still have 1 bit available to store other stuff, and 2 bits in non-leap years!

  • maldrich (cs) in reply to Mikademus

    Should probably be bInaryWORKDAY (Y/N)

    Can't believe I am suggesting naming improvements for this nightmare. I guess I need something to do....

  • Stephan (unregistered) in reply to Mikademus

    The really funny thing is that it should be called "tblWeekends".

  • jackass (cs)

    And it works great overseas.  All you have to do is create a new table and determine other countries holidays.

  • Colin (unregistered) in reply to Mikademus
    Mikademus:
    That threw me off, why are the non-holidays marked "Y"?!


    You see, when you get to work with code like that....each work day is just like a holiday.  I'm so super jealous.
  • orbis tertius (unregistered)

    laughable... this fellow clearly has no idea about enterprise systems.

    he should have had another table called "days", where each row contains the current date. a daily cron script can then kick off each day to add a row to the days table, which of course has a trigger that calls a stored procedure which automatically appends a "Y" or "N" to the proper row in blnaryHoliday.

  • John Hensley (unregistered) in reply to orbis tertius

    A more "enterprise" way to do this would be with two tables:

    one to enumerate holidays...

    and one to enumerate non-holidays!

  • DWalker59 (cs) in reply to orbis tertius

    I agree -- there are NO holidays listed in that table, only the weekdays are marked Y.  Apparently there are no holidays, or else every weekday is a holiday.

  • marvin_rabbit (cs) in reply to John Hensley
    Anonymous:
    A more "enterprise" way to do this would be with two tables:
    one to enumerate holidays...
    and one to enumerate non-holidays!

    Ah yes, then you have truly mastered Zen Programming.
  • ParkinT (cs) in reply to Sam
    Anonymous:

    Ken Nipper:
    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........

    I don't think "logic" is the way to go (not sure how you'd logically work out what the holidays would be, anyway -- plus, what happens when that "logic" changes?).  However, you could just put the dates in the table as dates, maybe with a nice little description for the holiday in a separate column.  Plus other column flags like which country it's a holiday for, or whether it's a trading or settlement holiday for finance, or whatever.

    Of course, logic works for weekends.  Is it just me who only sees weekends defined on this chart?

    The ENTERPRISE way to approach this problem is to use a simple CRON routine that;

    • each day contacts TheDailyWTF
    • compares the entry to 'yesterday'

    if it matches this must be a weekend or holiday!

     

    VOILA!

     

  • Martin (cs)

    Surely, this should have been ...

    <1975>
    <January>
    <1>Holiday</1>
    <2>Work</2>
    <3>Work</3>
    ...
    </January>
    ...
    </1975>
    ...

     

    or even

    \1975
      \January
        \1
          \Status.txt
        \2
          \Status.txt
    ...
    Where Status.txt contains whether or not the day is a holiday.

     

    (... hoping the forum does not screw the layout ...)

  • lol (unregistered) in reply to ParkinT
    ParkinT:
    Anonymous:

    Ken Nipper:
    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........

    I don't think "logic" is the way to go (not sure how you'd logically work out what the holidays would be, anyway -- plus, what happens when that "logic" changes?).  However, you could just put the dates in the table as dates, maybe with a nice little description for the holiday in a separate column.  Plus other column flags like which country it's a holiday for, or whether it's a trading or settlement holiday for finance, or whatever.

    Of course, logic works for weekends.  Is it just me who only sees weekends defined on this chart?

    The ENTERPRISE way to approach this problem is to use a simple CRON routine that;

    • each day contacts TheDailyWTF
    • compares the entry to 'yesterday'

    if it matches this must be a weekend or holiday!

     

    VOILA!

     



    rofl that is fuckin funny shit.
  • Maurits (cs)

    This is actually a GOOD approach... caching calculations.

    It should have been coupled with some kind of mechanism for generating rows for future years, though.

  • tiro (cs) in reply to Maurits

    Caching calculations MIGHT be a good approach IF it turns out the calcuation is a bottleneck.  You can't figgure that out without profiling it.  Even then we're assuming that it takes less time to go out to the database and parse that mess instead of doing the calculation in the first place.

    Either way, you can't know without profiling, and if it turns out that hitting the database is more efficient, well there's surely a better way of doing it than this bit of WTFery.

  • wunderkind (cs) in reply to Stephan
    Anonymous:
    The really funny thing is that it should be called "tblWeekends".


    You're close, but not quite there.

    It SHOULD be called "tblWeekdays"
  • Jeff S (cs) in reply to tiro

    Ok, I see "T" and "F", but what about "File not found?"

    In all seriousness, I would love to see the rest of this "database."  or maybe not.

    Great post Alex.  WTF ++ !

  • Jeff S (cs) in reply to Ken Nipper
    Ken Nipper:
    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........


    Holidays are *data* and should be stored in tables. 

    However, as mentioned, it appears that he is simply declaring every weekend a "Holiday" so in that case logic would work, I suppose.

    The guy who wrote this must be a fun guy to hang out with ... except for Monday-Friday or on any actual holiday that falls on a weekday, that is.
  • Database Architect (unregistered)

    If you want a real solution you should use the following table instead:

    CREATE TABLE
        tblHoliday
    (
        intYear   INT,
        bln0101   BIT,
        bln0102   BIT,

        bln0103   BIT,
        ...
        bln1231   BIT
    )

  • It's a Feature (cs) in reply to Maurits

    [:S]

    Okay--just so I don't end up the guy who has to make sense out of the WTFs for holidays--

    The right way to track holidays is to manually enter them into a table.  Most holidays can be mathematically calculated (3rd Monday of January, for example, for Martin Luther King's birthday), but some are rather complex in their formulas (every try to calculate Easter?)  Some years a business will observe one holiday, while on others it will observe a different holiday.  Safest to always just put the list of observed holidays in a database.

    And, for goodness sakes, just have a table with nothing but the actual date of the holiday:

     

    Holiday Table (or whatever you want to call it)

    Date  (a "Date" datatype, please)  | Description (optional column)

    12/25/2006                                  | Christmas

     

     

  • John Bigboote (cs) in reply to Mikademus
    Mikademus:
    That threw me off, why are the non-holidays marked "Y"?!


    Because that will be your response. "YYYYYYYYYYYYes! I get to go to work!"

    That's how awesome working for this company is.
  • Richard Nixon (cs) in reply to ParkinT
    ParkinT:
    Why are there Braille markings on the Drive-up ATM?


    1.    For blind people being driven to the ATM.
    2.   Notice there is Braille on all ATMs, including those walk-up ones in the mall and at banks. Does it make sense to manufacture some ATMs with Braille and some without? No, of course not - make one mold, keep filling it.
    3.   Americans with Disabilities act is probably another reason.

    There, three reasons for you. Change your signature.

    sincerely,
    Richard Nixon
  • HitScan (cs)

    Man, I bet the leap year code for this mess is hell awesome.

  • Ametheus (cs)

    When did Christmas stop being a holiday?

  • IQpierce (cs) in reply to Ametheus
    Ametheus:
    When did Christmas stop being a holiday?
    Obvious! This company only gives you a holiday off if that Holiday falls on a weekend
  • Kiwi (unregistered) in reply to Casiotone
    Casiotone:
    blnaryHoliday?

    booleanary?


    boolean array maybe
  • Rick (cs) in reply to Ametheus

    In the financial programming world, we all have 'holiday' tables. That part makes sense. Using a logic based solution would not be practical. Remember when Ronald Reagan died, the markets had a holiday added. Inserting one row into a 'holiday' table was easy, maintaining and releasing code is unfeasable.

    Not using a datetime field for the holiday dates is what makes no sense.Using a database in such a way, that you can't possibly 'JOIN' to the required data is the WTF.

  • Digitalbath (cs) in reply to jackass

    jackass:
    And it works great overseas.  All you have to do is create a new table and determine other countries holidays.

    You mean that not everyone celebrates the 4th of July?  Weird. [:D]

  • kipthegreat (cs) in reply to Ametheus
    Ametheus:
    When did Christmas stop being a holiday?


    During the War On Christmas, obviously.  I guess Christmas lost.
  • John Bigboote (cs) in reply to Ametheus
    Ametheus:
    When did Christmas stop being a holiday?


    When the Christmas-hating liberal media got hold of the calendar industry.
  • McDuck (unregistered)

    scrooge@gold> mysql -uscrooge -pm0n3y
    mysql> USE dbHoliday;
    mysql> UPDATE tblHoliday SET binaryHoliday = INSERT(binaryHoliday, LENGTH(binaryHoliday)-6, 1, 'Y');

  • HatTrick (cs) in reply to Sam
    Anonymous:

    Ken Nipper:
    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........

    I don't think "logic" is the way to go (not sure how you'd logically work out what the holidays would be, anyway -- plus, what happens when that "logic" changes?).  However, you could just put the dates in the table as dates, maybe with a nice little description for the holiday in a separate column.  Plus other column flags like which country it's a holiday for, or whether it's a trading or settlement holiday for finance, or whatever.

    Of course, logic works for weekends.  Is it just me who only sees weekends defined on this chart?

    What do you mean you can't use logic to calculate the holidays? There are rules for figuring out holidays and when they fall each year, they don't generally change. 

    And yes I think you're right, I also do not see any holidays defined in this, only weekends.

  • WTF Batman (cs) in reply to Jeff S
    Jeff S:
    Ok, I see "T" and "F", but what about "File not found?"

    In all seriousness, I would love to see the rest of this "database."  or maybe not.

    Great post Alex.  WTF ++ !


    In the end, it was decided that 'F' would signify both False and Filenotfound, in the interest of saving precious bytes of memory. A random number would be generated, and then the mod(2) taken, to determine which value the current instance of 'F' implied.
  • Bus Raker (cs) in reply to Jeff S

    Jeff S:
    Ken Nipper:
    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........


    Holidays are *data* and should be stored in tables. 

    However, as mentioned, it appears that he is simply declaring every weekend a "Holiday" so in that case logic would work, I suppose.

    The guy who wrote this must be a fun guy to hang out with ... except for Monday-Friday or on any actual holiday that falls on a weekday, that is.

     

    Sorry every holiday has an exact calculation ... in Excel for instance they can represented like:

    Memorial Day - Last Monday in May

    =DATEVALUE("5/" & IF(WEEKDAY(DATEVALUE("5/31/" & intYear))>3, 35 -WEEKDAY(DATEVALUE("5/31/" & intYear)),28-WEEKDAY(DATEVALUE("5/1/" & intYear))) & "/" & intYear)

    How you want to cache the results depends on your needs.

     

    I sure wouldn't want to work for that company.  No holidays!

     

  • WTF Batman (cs) in reply to WTF Batman
    WTF Batman:

    In the end, it was decided that 'F' would signify both False and Filenotfound, in the interest of saving precious bytes of memory. A random number would be generated, and then the mod(2) taken, to determine which value the current instance of 'F' implied.


    I should mention that the technical term for this logic is "WTF Overloading".
  • nobody (cs)

    This is actually GREAT! Finally a date system that can take leap-seconds into account on the scale of years :D

  • stephen (unregistered) in reply to Mikademus
    Mikademus:
    That threw me off, why are the non-holidays marked "Y"?!

    easy:
    yes == yes, it is not a holiday
    no == no, it is not not a holiday
  • marvin_rabbit (cs) in reply to Bus Raker
    Bus Raker:

    Jeff S:
    Ken Nipper:
    Hmmmm.......guess the original programmer thought it was more efficient to type Ys and Ns than to do say.........LOGIC...........


    Holidays are *data* and should be stored in tables. 

    However, as mentioned, it appears that he is simply declaring every weekend a "Holiday" so in that case logic would work, I suppose.

    The guy who wrote this must be a fun guy to hang out with ... except for Monday-Friday or on any actual holiday that falls on a weekday, that is.

     

    Sorry every holiday has an exact calculation ... in Excel for instance they can represented like:

    Memorial Day - Last Monday in May

    =DATEVALUE("5/" & IF(WEEKDAY(DATEVALUE("5/31/" & intYear))>3, 35 -WEEKDAY(DATEVALUE("5/31/" & intYear)),28-WEEKDAY(DATEVALUE("5/1/" & intYear))) & "/" & intYear)


    Cool!  Can you show me the formula for Easter next?
  • dmdietz (cs)

    The real WTF here is that the original programmer didn't have the foresight to insert the days as XML entries into the database.

Leave a comment on “Time for a tblHoliday”

Log In or post as a guest

Replying to comment #:

« Return to Article