You also need a year to get anything to be perfect, otherwise you would essentially just be guessing. The reason is leap year.
CREATE TABLE `test`.`so_week` (
`so_week_ID` INT UNSIGNED NOT NULL AUTO_INCREMENT ,
`from_week` INT UNSIGNED NOT NULL ,
`to_week` INT UNSIGNED NOT NULL ,
PRIMARY KEY (`so_week_ID`) );
# as far as I went
SELECT MONTHNAME(MAKEDATE(1980,7*from_week)) FROM so_week;
Trying to recreate datetime/month names and all of that is insane. You're fighting the current, just work with the normal date/datetime data-types. It will save you a massive headache at how incredibly complicated/intricate time is. If you want someone to blame it on, blame it on the Sumerians and Babylonians, they were the ones who came up with this sexagesimal numbering (base 60) system. it's worse than the American measuring system (inches, feet, cups, fail).
Edit: the simple answer is to store from_date and to_date instead of from_week and to_week. Also, making a table with the month names and then joining on it, is pure insanity. There are built in function, MONTHNAME(date) ^^ DATEFORMAT(date,format-string)) which are deterministic and will get the answer incredibly faster and lqtm, i remember when I did something like what you're doing.
Last edited by eval(BadCode); 08-14-2012 at 10:16 AM.
I use (, ; : -) as I please- instead of learning the English language specification: I decided to learn Scheme and Java;