Is there a standard way to represent dates which are a certain number of days before or after another date in an RDBMS?
For example, let’s say Date 1 is 30th October, 2005, which can obviously be stored in a datetime column or similar in the RDB.
But let’s say Date 2 is “3 days After Date 1”, how would you represent it in the RDB, assuming that Date 1 can be changed anytime in the future, which means Date 2 would have to be updated automatically somehow?
Thanks!!
Give 2 items of information, you can always work out the third
In this case, you appear to have 2 known facts
Store these and make “Another Date” a computed column with DATEADD
This way, AnotherDate will be maintained by the database engine as the 2 input values changes
If any of the 3 can change then you usually have to use a trigger…