On Mi, 1999-07-07 10:14:52 -0600, Ken without lastname wrote:
> I have a table that I want to preload with a couple years worth of dates,
> and attributes such as day of week, week or year, etc. I am wondering if
> MySQL has any functions that will do this. Yes, I know dayofweek(date),
> etc. works, but how to load a range of dates?
As far as I know it not possible directly.
In similiar cases I often use a work-around creating a simple
auxiliary table with only one INT field which holds the values from 1
to (say) 1000:
CREATE TABLE ints ( n INT NOT NULL AUTO_INCREMENT PRIMARY KEY );
And then repeat 1000 times (using some programming language, of course):
INSERT INTO ints VALUES (NULL);
Okay, now with the help of this auxiliary table you can easily select
a range of integers and use these to compute some other results, e.g.
a list of the next 10 months:
SELECT DATE_ADD(CURRENT_DATE, INTERVAL n MONTH)
WHERE n BETWEEN 1 AND 10;
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