I have an SQL fact table which is used for looking up a date and returning another date.
The table schema is as follows:
TABLE date_lookup
(
pk_date DATE,
plus1_months DATE,
plus2_months DATE,
plus3_months DATE
);
UNIQUE INDEX on date_lookup(pk_date);
I have a load file (pipe delimited) containing dates from 01-28-2012 to 03-31-2014.
The following is an example of the load file:
01-28-2012|02-28-2012|03-28-2012|04-28-2012|
01-29-2012|02-29-2012|03-29-2012|04-29-2012|
01-30-2012|02-29-2012|03-30-2012|04-30-2012|
01-31-2012|02-29-2012|03-31-2012|04-30-2012|
...
03-31-2014|04-30-2014|05-31-2014|06-30-2014|
The rules for this fact table are: If pk_date has more than 28 days in its month and plus1, plus2 or plus3_months only has 28, 29 or 30 days, then let plus1, plus2 or plus3 equal the last day of the following month.
My question is: Is it possible to use sed to generate more dates past 03-31-2014 following the above rules for my load file, or should I write a program to accomplish this?
dateadd(), datediff()and similar functions that make this very easy to compute. It may be possible to do this in sed, but would be torture to create and a fireable offence at most organization to check it in as code that someone else may have to maintain ;-)! Good luck. – shellter Jul 16 '12 at 4:35