Default column value using default or formula properties

Posted on 2006-06-12
Last Modified: 2010-05-18
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....
Question by:johnnyg123
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2

Expert Comment

ID: 16889728
Yes you can use a trigger to that,
but why you want to store that data ? when you can derive it at any time

Author Comment

ID: 16889830
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?

Expert Comment

ID: 16889856

Accepted Solution

Netminder earned 0 total points
ID: 16932443
Closed, 500 points refunded.
Site Admin

Featured Post

[Live Webinar] The Cloud Skills Gap

As Cloud technologies come of age, business leaders grapple with the impact it has on their team's skills and the gap associated with the use of a cloud platform.

Join experts from 451 Research and Concerto Cloud Services on July 27th where we will examine fact and fiction.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
For both online and offline retail, the cross-channel business is the most recent pattern in the B2C trade space.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
Via a live example, show how to shrink a transaction log file down to a reasonable size.

617 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question