The Coding Monkey

Wednesday, November 02, 2005

How Come The Application Broke?

Today one of my project leaders came by and asked for help figuring out why one of our production systems that I helped work on broke suddenly. We hadn't touched the code in months, so we had no clue what would have suddenly changed. My initial thought was that because it threw an unknown exception at application startup, some needed libraries had been removed or something. After doing a couple minutes of debugging, we found out the problem was a little simpler than that:

StartDate = New Date(Now.Year, Now.Month + 2, 1)

EndDate = Date.Now.AddMonths(2)

And yesterday was November 1st! Doh! Sadly... there is no 13th month in the year, and the Date constructor doesn't rollover properly in this case. Thanfully I didn't write this code... but still had to help fix it. Don't you hate it when really trivial stuff kills you? Hmmm... sorta like Office Space:

Michael Bolton: Ok! Ok! I must have, I must have put a decimal point in the wrong place or something. Shit. I always do that. I always mess up some mundane
Peter Gibbons: Oh! What is this fairly mundane detail, Michael?!!!!!


  • I once wrote code that determined the date/time from a timer value (I think it was the timer built into the C libraries).

    The code worked great, because I tested it during the later part of a leap year! Before Feb 29th it still added an EXTRA day. If I remember correctly: the code worked fine for some non leap years (depending on where they were in relation to the next leap year) and days after Feb 29th. I was lucky to catch it before it shipped. I had a good laugh at my own expense.

    By Blogger Aaron, at November 04, 2005 10:16 PM  

  • I always heard Peter's line as:
    Oh! Well this is not a mundane detail, Michael!

    My DVD subtitles agree with me. ;-)

    By Anonymous Michael Wardle, at November 05, 2005 6:08 AM  

  • Yeah I know... I sorta realized it was wrong after I posted but didn't fix it. I was lazy and just copy and pasted the text from a movie script site which had that.

    So thats probably how it was supposed to be. Oh well.

    By Blogger Nick, at November 06, 2005 6:27 AM  

Post a Comment

<< Home