List:General Discussion« Previous MessageNext Message »
From:Martin Ramsch Date:September 28 1999 5:09pm
Subject:Re: About ISO week # formatting in MySQL
View as plain text  
On Tue, 1999-09-28 22:37:08 +0700, Aldrian Gintingsuka wrote:
> How about having the week function returning a value relative to a certain
> year? 
> 
> week('1981-12-31,1,1981) -> 53
> week('1982-01-01,1,1981) -> 53
> 
> week('1981-12-31,1,1982) -> 0
> week('1982-01-01,1,1982) -> 0

Plus taking the moon phase into account, too? ;-)

Seriously, no, I don't think this is good an idea!

This year parameter only makes sense with the current year and the
following or previous year, so a parameter with possible values -1, 0,
or 1, meaning relative to last year, this year, next year, would make
a little bit more sense.  But even then, this parameter only makes
sense for the few days at the very beginning and end of year, so it's
a _very_ special parameter and doesn't fit that good into a general
week function.  And last but not least, as I see it you easily can
deal with a week 0 and transform that to whatevery you like, because
it's meaning is clear - so the current functionality is quite usable!
For example, if your eally want to map week 0 to 53, you might use
  IF( WEEK(datefield)=0, 53, WEEK(datefield) )
Besides being a little bit longish it's easy.

Regards,
  Martin
-- 
Martin Ramsch <m.ramsch@stripped> <URL: http://home.pages.de/~ramsch/ >
PGP KeyID=0xE8EF4F75 FiPr=52 44 5E F3 B0 B1 38 26  E4 EC 80 58 7B 31 3A D7
Thread
About ISO week # formatting in MySQLJuan Riera26 Sep
  • About ISO week # formatting in MySQLMichael Widenius26 Sep
  • RE: About ISO week # formatting in MySQLJuan Riera27 Sep
    • RE: About ISO week # formatting in MySQLAldrian Gintingsuka27 Sep
    • RE: About ISO week # formatting in MySQLMichael Widenius27 Sep
      • RE: About ISO week # formatting in MySQLbkline28 Sep
        • RE: About ISO week # formatting in MySQLPeter Strömberg28 Sep
      • Re: About ISO week # formatting in MySQLMartin Ramsch28 Sep
        • Re: About ISO week # formatting in MySQLPeter Strömberg28 Sep
          • Re: About ISO week # formatting in MySQLAldrian Gintingsuka28 Sep
            • Re: About ISO week # formatting in MySQLMartin Ramsch28 Sep
            • Re: About ISO week # formatting in MySQLBob Kline28 Sep
          • Re: About ISO week # formatting in MySQLMatthias Urlichs28 Sep
            • Re: About ISO week # formatting in MySQLPeter Strömberg28 Sep
              • Re: About ISO week # formatting in MySQLMichael Widenius29 Sep
            • Re: About ISO week # formatting in MySQLBob Kline28 Sep
              • Re: About ISO week # formatting in MySQLMatthias Urlichs29 Sep
          • RE: About ISO week # formatting in MySQLJuan Riera30 Sep
            • Re: About ISO week # formatting in MySQLMartin Ramsch30 Sep
        • Re: About ISO week # formatting in MySQLMartin Ramsch28 Sep
          • Re: About ISO week # formatting in MySQLBob Kline28 Sep
            • Re: About ISO week # formatting in MySQLMartin Ramsch28 Sep
              • Re: About ISO week # formatting in MySQLBob Kline28 Sep
                • Re: About ISO week # formatting in MySQLMartin Ramsch28 Sep
                  • Re: About ISO week # formatting in MySQLBob Kline29 Sep
                • Re: About ISO week # formatting in MySQLMartin Ramsch29 Sep