Default column value using default or formula properties

I have a date column on my table defined as datetime (call_date) (not necessarily current date)

I also have 2 columns named  call_month and call_year ( both defined as varchar).

I would like the call_month and call_year values to be defaulted to month and year portions of call_date respectively.

Is it possible to do this using the default or formula values for the field definitions?

For example if call_date is 5/24/06....call_month would default to 5 and call_year would default to 06

I know I could do this using a trigger but just curious....
Who is Participating?
Closed, 500 points refunded.
Site Admin
Yes you can use a trigger to that,
but why you want to store that data ? when you can derive it at any time
johnnyg123Author Commented:
I needed it to make it easier to do reporting .....actually...I figured it out

for call_month

(case when ([FOTCCallDate] is not null) then (datepart(month,[FOTCCallDate])) else '' end)

for call_year

(case when ([FOTCCallDate] is not null) then (datepart(year,[FOTCCallDate])) else '' end)

How can I close this case?
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.