These are the columns (simplifying):
myDate as Date
theMonths as int
Then I create a computed column finalDate
in Microsoft SQL Server Management Studio 2008 R2, with this formula:
(dateadd(month, theMonths, myDate))
Very simple. But there is an error:
Error validating formula
The error occurs only if I insert the formula through the integrated assistant in Management Studio. Not occurs when create column through T-SQL query.
If I change myDate
type to Datetime
, there's no error, but I can't change the table structure.
I try this:
(dateadd(month, theMonths, CONVERT(Datetime, myDate)))
The error persists.
I created the column directly in T-SQL using the following:
ADD [finalDate] AS (dateadd(month,[theMonths],[myDate])) PERSISTED
It works fine, the column is created, the data is computed when insert-update. The problem is in the Management Studio.