• Sum Fag (unregistered) in reply to Colin
    Anonymous:
    For mysql:

    ...where date_format(curdate(), '%m %e')=date_format(BirthDay, '%m %e') or date_format(date_add(BirthDay, interval 1 day), '%m %e')=date_format(date_add(curdate(), interval 1 day), '%m %e');


    Ewww ... he hangs around with MySQL!
  • Surge (unregistered)

    Why bother doing date parsing in SQL anyway? Just get all unique customer ID and email
    and shove it into something like PHP/C/[insert favourite langauge] and parse
    date from there.

    If you were really picky about performance loss due to pulling out ALL the entries,
    just SELECT entries by today's month only and pass that to your script.
    You have to pass the data to your script/program anyway, to be able to send email.

  • (cs)

    Everybody is focusing on leapyears, but really isn't the WTF that the coupon email is being sent on a specific day?  I mean, do you want to go poking around in there if the code doesn't run for some reason for a day or two and you have to back up time in order to send out belated birthday coupons?

    "No Problem, just roll back the system date and re-run it!!"

    And there's no check field to store if coupon has already been sent.  At least none that we can see.

    Birth days are always a bitch, better to use birth week.

  • (cs) in reply to johnl
    johnl:
    Why not simply say that if your birthday is after the 28th, then it sends you a coupon on the 28th?


    A lazy programmer .. one of the great virtues.
  • rien (unregistered) in reply to GoatCheez
    GoatCheez:
    <sarcasmn>See, now all this date nonsense could be COMPLETELY avoided if we were to use 16 months in a year, 16 days in a month, and 16 hours in a day. I mean seriously people, we are using ANCIENT date technology. Of course, with 16 days in a month, a week would be 4 days long, and the weekend would be 1 day...  but it all works out ;-) </sarcasmn>


    reminds me of the simpler calendar

    --
    rien

  • rien (unregistered) in reply to rien
    Anonymous:

    reminds me of the simpler calendar


    i meant simpler calendar

    -- rien

    ps: that's true, this forum software s****...

  • (cs) in reply to Djinn

    Actually, I'd have recommended the same thing.

    A) Last minute fix

    B) The importance of receiving it one day before your birthday to someone born on the 29th is probably not that high and that, statistically, there aren't very many people whom might be affected by this triviality.

    C) How are you going to guarantee the coupon shows up in the mail on someone's birthday anyway?  If their birthday is on Sunday they're SOL.  If their birthday is December 25th (or any other federal holiday that the post office gets off) they're not getting the coupon on time either.    At what point do you just accept that with the calendar some things are simply "close enough" and not paint yourself into a corner of doing really complicated date/time logic when it only solves a problem with one statistical outlier and does nothing at all to fix a much larger body of statistical anomalies?

  • (cs)

    Strangely, my post didn't quote Djinn whom said:

    >A lazy programmer .. one of the great virtues.

    Whom was replying to: "Why not simply say that if your birthday is after the 28th, then it sends you a coupon on the 28th?"

     

  • (cs)
    Alex Papadimoulis:

    Steve looked over the code and was impressed: this time the query only ignores those born on the 29th in a non-leap year. His coworker went back and forth between the drawing board and Steve a few more times, until he finally gave up and told the clients that implementing such a feature was technically not feasible.

    Steve shoulda out-sourced the project after the second episode.

  • (cs) in reply to olddog
    olddog:
    Alex Papadimoulis:

    Steve looked over the code and was impressed: this time the query only ignores those born on the 29th in a non-leap year. His coworker went back and forth between the drawing board and Steve a few more times, until he finally gave up and told the clients that implementing such a feature was technically not feasible.

    Steve shoulda out-sourced the project after the second episode.

    I guess that, to me, the real WTF is that Steve let the programmer say such a thing to a client.

  • (cs) in reply to AtomicTesting
    AtomicTesting:

    Actually, I'd have recommended the same thing.

    A) Last minute fix

    B) The importance of receiving it one day before your birthday to someone born on the 29th is probably not that high and that, statistically, there aren't very many people whom might be affected by this triviality.

    C) How are you going to guarantee the coupon shows up in the mail on someone's birthday anyway?  If their birthday is on Sunday they're SOL.  If their birthday is December 25th (or any other federal holiday that the post office gets off) they're not getting the coupon on time either.    At what point do you just accept that with the calendar some things are simply "close enough" and not paint yourself into a corner of doing really complicated date/time logic when it only solves a problem with one statistical outlier and does nothing at all to fix a much larger body of statistical anomalies?

    Absolutely bang on target. The real WTF is the short-sighted client. Most marketing efforts are sent out well in advance of a target date - to ensure plently of time for unforseen delivery issues.  The time-frame is *way* to compressed. The client is the real knuckle-head. - Probably reacting to a qualified suggestion from the sales department.

    This supports what I've been saying for years... "We gotta find a way to do business without clients."

  • DrDoom (unregistered) in reply to ChiefCrazyTalk

    Anonymous:
    What I really want to know is, what kind of customer is going to believe a developer that tells them it is "not feasible" to determine if it is the day before someones birthday!

    I was presenting one of my programs one day to a group of managers prior to it release into production. The code was written in less then 1 hour but would have saved some administrators including my self around 2 hours a day. It connected to AD and our DB and provided a basic report.

    <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p> </o:p>

    Managers who knew the process were impressed. At the end of the meeting I was told by one of the managers that it took more then 2 hour for 8 people (7 managers +1 consultant from unnamed vendor) to determine that what I just did was impossible within time and budget constrains of one month and a lot of $.

    <o:p> </o:p>

    I have spent another 4 hours documenting the code and sent it to our testing team. A week later I asked if the software has been approved. It turns out that some managers took my cations as criticism of their management and decision making abilities and blocked the release. The reason was simple – They “did not what the code did.”

    [*-)]

  • DrDoom (unregistered) in reply to DrDoom

    Sorry for the spelling mistakes. I am on 4 hours of sleep. <?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" /><o:p></o:p>

    "managers took my actions" and  They “did not know what the code did.” I am sure there are more. <o:p></o:p>

    LOL, English is my third language. <o:p></o:p>

     

  • Plonk (unregistered) in reply to Stew

    The word 'seppo' itself is not Cockney in origin as far as I am aware (although the rythming slang pattern is). I always thought it was Australian and I think it had it's origins in WWII.

    http://english2american.com/dictionary/cat_people.html

  • Miles Thompson (unregistered) in reply to Ytram
      I thought that people who are born on Feb 29th, usually officially declare their birthday as either February 28th or March 1st, so it still shouldn't be an issue.

      Technically though,if they put in their birthdate as 2/29, then their birthday only comes every four years(excluding the century exclusions of course), so the query is correct.

    Yeah, this is the correct behaviour in my opinion. My grandfather was born Feb 29 1888. We celebrated his 21st "birthday" when I was a kid and he was 88 in elapsed years.

    We even got a picture in the paper of him surrounded by all his grandkids celebrating his '21st' birthday. As far as he (and my great grandparents) were concerned he just lucked out on the birthday stakes and so he only got a birthday every four years but apparently he got lots more attention whenever that did happen. Worst luck was being born just before the century so he didn't even get a 12th birthday. On the other hand, being born in Glasgow, Scotland, just before the turn of the century, I imagine presents might have consisted of a pat on the back and maybe an orange if you were lucky but probably not. (cf Monty Python Four Yorkshiremen Sketch - I don't want to dishonour Mac's name by making the joke myself but you can imagine it).

    So yeah. If you happen to be 'lucky' enough to have a birthday on the leap day, then I imagine not getting promtional birthday cards from some sorry arse marketing firm that you don't care about anyway is not top on your priority list.

     

  • (cs) in reply to Richard Nixon
    Richard Nixon:
    cconroy:
    <font size="2">The real WTF is that people still use coupons.

    </font>


    I got a $300 television from Best Buy for $5, out of the store - no rebates, only coupons.


    www.newsaves.com
  • Nobody (unregistered) in reply to AtomicTesting
    AtomicTesting:

    Actually, I'd have recommended the same thing.

    C) How are you going to guarantee the coupon shows up in the mail on someone's birthday anyway?  If their birthday is on Sunday they're SOL.  If their birthday is December 25th (or any other federal holiday that the post office gets off) they're not getting the coupon on time either.

    You mean your e-mail doesn't get delivered on Sunday or holidays? It's talking about coupons being sent to e-mail addresses....the first SQL statement contains the clue.

  • (cs)
    Alex Papadimoulis:

    He showed Steve the above code, unsure of why it didn't return any customers. Steve explained that his query will only find customers who have not been born yet, so he went back to the drawing board ...

    <FONT color=#0000ff>SELECT</FONT> CustomerId, EmailAddress
      <FONT color=#0000ff>FROM</FONT> Customers
     <FONT color=#0000ff>WHERE DATEPART</FONT>(day, Birthdate) = <FONT color=#0000ff>DATEPART</FONT>(day, Today() + 1)
       <FONT color=#0000ff>AND DATEPART</FONT>(month, Birthdate) = <FONT color=#0000ff>DATEPART</FONT>(month, Today() + 1)

    <FONT size=2>I think the query just needs an OR.</FONT>

    <FONT face="Courier New" size=2>-------------------------
    SELECT
        CustomerId,
        EmailAddress
    FROM
        Customers
    WHERE // TOMORROW IS THE BIRTHDAY
        ( 
        DATEPART(day, Birthdate)   = DATEPART(day,   Today() + 1)
    AND DATEPART(month, Birthdate) = DATEPART(month, Today() + 1)
        )
    ------------------------------</FONT>

    <FONT size=2>so assuming that today() returns a date, and today()+1 returns tomorrow, the real test is for tomorrow.</FONT>

    <FONT face="Courier New" size=2><FONT face=Tahoma>there is only one possible exception... that being FEB 29.
    lets add.... </FONT></FONT>

    <FONT face="Courier New" size=2><FONT face=Tahoma>
    </FONT>-------------------------
    OR  (
     
        ( DATEPART(day, Today() + 1 ) = 1 ) // TOMORROW IS THE FIRST OF THE MONTH
    AND ( DATEPART(day, Birthdate) > DATEPART(day, Today()) ) // AN OVER-RUN</FONT>

    <FONT face="Courier New" size=2>    ) //....then it must be a leap year baby and it must be FEB.</FONT>

     

  • Anonymous Timekeeper (unregistered) in reply to rien
    Anonymous:
    Anonymous:

    reminds me of the simpler calendar


    i meant simpler calendar

    -- rien

    ps: that's true, this forum software s****...



    I prefer the one with 13 months all with 28 days, you always know what day of the week any day of the month is (e.g. 1st, 8th, 15th, 22nd are always Sunday, etc.)  and there are only two special days, New Years Day and Leap Day.

  • (cs) in reply to TankerJoe

    ahhh!!!! it looks way too much like lisp...

  • (cs) in reply to SeekerDarksteel
    SeekerDarksteel:
    SeekerDarksteel:

    Anonymous:
    Hang on, that last query would work, wouldn't it?

     

    Mostly, yes.  The problem is that if it isn't a leap year then February 29th will never happen and the people born on February 29th would not get the birthday messages for that year.  What is funny is that it would be relatively trivial to check for February 28th and return records for both people born on the 28th and the 29th.

     

    As some other people have pointed out while I posted, it is not that trivial from within the query itself.  It would however be trivial in the logic surrounding the code that calls this query to check the date and whether or not it is a leap year and call one of several different queries depending on the results, one for 28th non-leap year, one for 28th in a leap year, and one for 29th in a leap year. 



    Can anyone here spell 'loosely coupled'? (In the app. login indeed ....) :|
  • (cs) in reply to kipthegreat
    kipthegreat:
    Anonymous:

    (I once read that the septics use less commas than the brits do in their version of english, so I guess communication failures across the pond are inevitable)



    I, as an American, who, incedentally, is not familiar with the term "septic," except as relating to a tank full of shit, would like to state, for the record, that I proudly, and frequently, use commas, even though I reside, as you may have guessed, on the \X/estSide of the Atlantic Ocean, or, as you insist on referring to it, the "pond."


    OMG, I just fell right off my chair.......... You go girl!!!!
  • Raw (unregistered) in reply to ray

    I know one person born on Feb 29, and he adamantly states his age according to the number of "real birthdays" he has had, approximately his real age divided by four.

    You can not begin to understand how many wrenches this throws into the machinery of various systems.

    He actually tried to use this to get out of military service, and I've seen hem spend 20 minutes argueing that he should only pay for a child ticket for the train (and eventually succeeded, mostly because the queue behind him were beginning to look like a mob).

    In other words, the code may not be that much wrong...

  • (cs) in reply to Raw

    Gilbert and Sullivan used leap years as a crucial point in their Pirates of Penzance musical.

    Pirate King: You were apprenticed to us!

    Frederick: Until my twenty-first year.

    Pirate King: No... until your twenty-first birthday - and going by birthdays you are, as yet, only five... and a quarter.

    ...

    Frederick: I've bound myself to serve the pirate captain... until I reach my one-and-twentieth birthday!

    Mabel: But you are twenty-one!

    Frederick: I've just discovered that I was born in leap year... and that birthday will not be reached by me till 1940.

    Given that the play begins when Frederick is twenty-one years old... what year is it?

  • (cs) in reply to Raw

    The article says "the query only ignores those born on the 29th in a non-leap year" and I thought to myself "nobody is born on the 29th in a non-leap year".

    Apart from the point, already made, that there are plenty of "29th's" in every year, including non-leap years, we've got a programmer who couldn't quite figure out how to overcome the error pointed out to him ... about the roughly 0.06% of people who might not get a coupon in the suggested code.  That is, less than one birthday out of 1460 might not result in a celebrant being given his or her due.

    So the manager claimed it was infeasible, rather than merely delivering 99.9993% of the coupons management wanted to deliver.

    Yeah, that's an error I'd cancel whole projects about.

  • Steveo (unregistered) in reply to Dave
    Anonymous:

    I don't believe this for a minute! Do you think I was born yesterday?



    Well, my money's on the early hours of this morning 
  • Wang (unregistered) in reply to Steveo

    SELECT CustomerId, EmailAddress
      <FONT size=+0>FROM</FONT> Customers
    <FONT size=+0>WHERE</FONT> dbo.anniversary(Birthdate) = 'Y'

     

    Simple really.

  • Doctor Pizza (unregistered)

    I would argue that the second query is absolutely correct.  I don't really see the WTF here.  By convention, the leap year lepers only have a birthday every fourth year.

    Pirates of frigging Penzance, anyone?

     

  • Doctor Pizza (unregistered) in reply to Doctor Pizza

    Oh curses.  I should have read the second page.  Some scurvy dog has already pointed out the Pirates of Penzance.

     

     

     
  • (cs) in reply to cconroy

    cconroy:
    <FONT size=2>The real WTF is that people still use coupons.

    </FONT>

    For marketeers they're great. Print a million coupons worth $5 each, claim you're giving away $5 million.
    In reality only a few thousand get turned in, actual cost maybe $15000 plus the cost of printing and distributing the darn things (which is even less, and zero if you make them "downloadable" which is the current trend).

    The suckers are the customers who prefer coupons over real discounts :)

  • (cs) in reply to not a bit brit
    Anonymous:

    I once read that the brits need correcting from the STs on the usage of "less" versus "fewer".

    No, they just need reminding that not everyone knows their language well enough to know the difference.

  • Nick (unregistered) in reply to jmeyer43

    jmeyer43:
    Ha!  Obviously he means that it's not feasible without programming knowledge, something absent from his miniscule head!

     

    Spelt "minuscule"...

  • Sigh (unregistered) in reply to Surge
    Anonymous:
    Why bother doing date parsing in SQL anyway? Just get all unique customer ID and email
    and shove it into something like PHP/C/[insert favourite langauge] and parse
    date from there.

    If you were really picky about performance loss due to pulling out ALL the entries,
    just SELECT entries by today's month only and pass that to your script.
    You have to pass the data to your script/program anyway, to be able to send email.

    That is a WTF. And... if you only pull out entries for current month, then you totally ignore everyone both on the 1st of the month.

  • Sigh (unregistered) in reply to Sigh

    Now, why don't we start looking at the code behind this forum for some serious jaw-dropping WTF?!

  • (cs) in reply to bugsRus

    Just another solution: build a time-machine

  • Ant (unregistered) in reply to TankerJoe

    TankerJoe:


    Let us, (meaning all of us (who are reading this (on TDWTF (using a browser (or RSS or Email))))) not be redundant.

    Can't help it. I've worked for the Department of Redundancy Department far too long.

  • (cs) in reply to Miles Thompson

    "(cf Monty Python Four Yorkshiremen Sketch - I don't want to dishonour Mac's name by making the joke myself but you can imagine it)."

    Just to clarify: that sketch actually predates Monty Python - it was originally in "At Last The 1948 Show" (see http://en.wikipedia.org/wiki/At_Last_the_1948_Show), but it was MP who made it famous.

  • (cs) in reply to Sigh

    Actually, Atomic, I think Djinn was agreeing with me as well.

    A lazy programmer can be a good or bad thing.  A programmer who's so lazy as to not put proper error checking in his code, or test it properly, is a bad thing.  A lazy programmer who's lazy because he still wants to do loads of stuff, but without the workload, is a good thing.

    I'm responsible for building all our assemblies, running unit tests on them and putting them on the correct servers.  I'm so lazy that I don't want to do it manually so I set up a continuous integration and automated build system, and now all I have to do is sit back and watch it do all the work.

    :)

  • foshizzle (unregistered) in reply to Richard Nixon
    Richard Nixon:

    I got a $300 television from Best Buy for $5, out of the store - no rebates, only coupons.


    Try shopping in New Orleans sometime. I got one for free - no rebates, no coupons, only one crowbar...
  • (cs) in reply to Raw

    "and I've seen hem spend 20 minutes argueing that he should only pay for a child ticket for the train (and eventually succeeded, mostly because the queue behind him were beginning to look like a mob). "

    If I were the ticket inspector I would gave him three options

       1º) He is an adult and must pay like it

       2º) He isn't one and is travelling with his parents -> that's ok

       3º) He isn't one and is not travelling with his parents

          3.1º) If he has a note authorizing him to travel alone -> that's ok

          3.2º) If he doesn't have it -> I should report the authorities for a possible kidnapping

  • (cs) in reply to ray
    ray:
    SeekerDarksteel:
    SeekerDarksteel:

    Anonymous:
    Hang on, that last query would work, wouldn't it?

     

    Mostly, yes.  The problem is that if it isn't a leap year then February 29th will never happen and the people born on February 29th would not get the birthday messages for that year.  What is funny is that it would be relatively trivial to check for February 28th and return records for both people born on the 28th and the 29th.

     

    As some other people have pointed out while I posted, it is not that trivial from within the query itself.  It would however be trivial in the logic surrounding the code that calls this query to check the date and whether or not it is a leap year and call one of several different queries depending on the results, one for 28th non-leap year, one for 28th in a leap year, and one for 29th in a leap year. 



    Can anyone here spell 'loosely coupled'? (In the app. login indeed ....) :|

     

    Yep, cause that's certainly the reason that the programmer claimed it was technically unfeasable.  Not because he couldn't come up with the most obvious (and yes, less desirable) solution (but a solution nonetheless).  But because it was loosely coupled.  Yep yep. 

  • (cs) in reply to Maurits
    Maurits:

    ...

    Given that the play begins when Frederick is twenty-one years old... what year is it?



    WTF?
    According to my watch, it's 2006. 
    Is this a trick question, or something?
  • (cs) in reply to Raw

    I know one person born on Feb 29, and he adamantly states his age according to the number of "real birthdays" he has had, approximately his real age divided by four.

    Tell him he can't drink, vote, drive, get a credit card or loan, watch rated movies or play rated games, and he has to be in bed by 9PM with all his homework done.  Until he's something like 230 actual years old...

  • (cs) in reply to johnl

    Actually if it's based on a factor of 4 then it'd be something like 80-odd.  Still worth trying though.

  • (cs)

    Assuming the RDBMS supports a MOD function, something like this should do the trick:
    <font style="color: rgb(0, 0, 255);" size="1">SELECT CustomerId, EmailAddress
    FROM Customers
    WHERE
    (
       DATEPART(day, Birthdate) = DATEPART(day, Today() + 1)
       AND DATEPART(month, Birthdate) = DATEPART(month, Today() + 1)
    )
    OR
    (
       DATEPART(day, Today()) = 28
       AND DATEPART(month, Today()) = 2
       AND
       (
          mod(DATEPART(year, Today()), 4) <> 0
          OR
          (
            mod(DATEPART(year, Today(), 100) = 0
            AND mod(DATEPART(year, Today(), 400) <>  0
          )
       )
       and DATEPART(day, Birthdate) == 29
       and DATEPART(month, Birthdate) = 2
    )
    </font>
    i.e. Either tomorrow is the customer's birthday or today is February 28th, it's not a leap year, and the customer's birthday is the 29th.

    Considering this code is unlikely to still be in use in the year 2100, it can simplified to:
    <font style="color: rgb(0, 0, 255);" size="1">SELECT CustomerId, EmailAddress
      FROM Customers
     WHERE
     (
       DATEPART(day, Birthdate) = DATEPART(day, Today() + 1)
       AND DATEPART(month, Birthdate) = DATEPART(month, Today() + 1)
     )
     OR
     (
       DATEPART(day, Today()) = 28
       and DATEPART(month, Today()) = 2
    </font><font style="color: rgb(0, 0, 255);" size="1">   -- will not work properly in years divisible by 100.
    </font><font style="color: rgb(0, 0, 255);" size="1">    and mod(DATEPART(year, Today()), 4) <> 0
       and DATEPART(day, Birthdate) == 29
       and DATEPART(month, Birthdate) = 2
     )</font>

    Alternatively, you could write a function that takes a birthday and returns the day to send the card (based on the business rules implied in the original queries: the day before the birthday or the 28th if it's not a leap year and the customer's bday is 2/29) and then rewrite the query as:
    <font style="color: rgb(0, 0, 255);" size="1">SELECT CustomerId, EmailAddress
     FROM Customers
    WHERE
    </font><font style="color: rgb(0, 0, 255);" size="1">dayToSendCard(Birthdate) =  </font><font style="color: rgb(0, 0, 255);" size="1">trunc(Today())

    </font>In Oracle, Trunc(<date>) strips off the hours and minutes . i.e. It returns a timestamp equivalent to midnight of the passed in date. You need to truncate the date or the code will only work if you run at EXACTLY midnight.  Substitute trunc for whatever method is used by this RDBMS to accomplish the same thing.
    <font style="color: rgb(0, 0, 255);" size="1"></font>

    Or you can tell the client that it's technically impossible. If your clients can be placated by telling them that, then they probably getting what they deserve. Why bother implementing anything when the company is doomed to fail.

  • (cs) in reply to olddog
    olddog:
    The real WTF is the short-sighted client. Most marketing efforts are sent out well in advance of a target date - to ensure plently of time for unforseen delivery issues.  The time-frame is *way* to compressed. The client is the real knuckle-head. - Probably reacting to a qualified suggestion from the sales department.

    This supports what I've been saying for years... "We gotta find a way to do business without clients."

    You're assuming that the coupon is only good on their birthday?

  • (cs) in reply to avery
    avery:
    Considering this code is unlikely to still be in use in the year 2100<date>


    AAAHHH!!! NOOOOOO!!!
    </date>
  • (cs) in reply to Anonymoose
    Anonymoose:
    Maurits:

    ...

    Given that the play begins when Frederick is twenty-one years old... what year is it?



    WTF?
    According to my watch, it's 2006. 
    Is this a trick question, or something?


    A crucial factor is deciding whether Frederick is smart enough to realize that 1900 isn't a leap year.
  • captain damage (unregistered)

    I would take the approach of a function which determines when your birthday is celebrated.

    select ... where will_celebrate_birthday_today( birthdate );

    function will celebrate_birthday_today
        bmonth = month( birth );
        bday = day( birth );

        tmonth = month( today );
        tday    = day( today );

        if ( bmonth == 2 ) and ( bday == 29 ) then
           # no changes in the case of today being Feb.29
           if not ( (tmonth == 2 ) and (tday == 29) ) then
             # leap year babies celebrate on Mar.1
             bmonth = 3;
             bday = 1;
           endif
        endif

        return ( bmonth == tmonth ) and ( bday == tday );

  • (cs) in reply to captain damage

    100th reply!

Leave a comment on “A Happy Happy Birthday”

Log In or post as a guest

Replying to comment #:

« Return to Article