- From SQL Server Management Studio, right-click on the target table and select Modify.
- Select the desired column in Object Explorer then move down to the Column Properties section.
- In the Default Value or Binding field, enter:
(dateadd(year, 30, getdate()))
This sets the value to 30 years from the date that the record is entered (unless a value is actually specified during entry). - Save your changes.
- You may of course, use different timespans by simply modifying dateadd. For more information, try Google.
21 February 2008
How do I set the default value or binding to a date in the future?
In this article, we will be using SQL Server's Default Value or Binding property to set the default column value to a date in the future. This can be useful if you have a value that you want to expire on a specific date from it's creation.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment