johnnyg123
asked on
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....
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....
ASKER
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,[FOTCCallD ate])) else '' end)
for call_year
(case when ([FOTCCallDate] is not null) then (datepart(year,[FOTCCallDa te])) else '' end)
How can I close this case?
for call_month
(case when ([FOTCCallDate] is not null) then (datepart(month,[FOTCCallD
for call_year
(case when ([FOTCCallDate] is not null) then (datepart(year,[FOTCCallDa
How can I close this case?
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
but why you want to store that data ? when you can derive it at any time