January 20, 2006 at 5:35 am
Hi,
When entering a date in column a, I need a date to be entered in automatically in columns b and c. The dates in columns b and c should be calculated from the date entered in column a: for example the date in col b should be 1 year on from the date in column a and the date in col c should be 30 days prior to the date in col b. Anyone any ideas on the best way to do this?
Thanks
Bob
BJ
January 20, 2006 at 6:02 am
Hi,
something like that maybe...
INSERT [YourTable] (columna, columnb, columnc)
SELECT [YourDate] , DATEADD(yy, 1, [YourDate]), DATEADD(dy, -30, DATEADD(yy, 1, [YourDate]))
January 20, 2006 at 7:42 am
If the other 2 dates are always going to have the same relationship to the first date, I would use a view as an interface to the table, and would only store the first date in the table.
So the table would have id, date1, col3, col4, col5.. and the view would select id, date1, date2(calculated from date1), date3(calculated from date1), col3, col4, col5..
I just depends on what you plan on doing with the date data. If it's possible that date1 will change, but you'll want to keep date2 and date3 the same, than it's better in just the table.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply