|
Posted by --CELKO-- on 03/04/07 15:41
SQL is a set-oriented language, not a computational language. Create
a table of reporting periods and use a BETWEEN predicate:
CREATE TABLE ReportPeriods
(period_name CHAR(7) NOT NULL PRIMARY KEY,
start_date DATETIME NOT NULL,
end_date DATETIME NOT NULL,
CHECK (start_date < end_date));
INSERT INTO ReportPeriods VALUES ('2007-01', '2007-01-01', '2007-01-31
23:59:59.99);
etc.
Now adjust the ranges to account for holidays, promotions etc.
Navigation:
[Reply to this message]
|