Re: simple year column

From: DanHW <danhw_at_aol.com>
Date: 1998/03/26
Message-ID: <1998032601092900.UAA20244_at_ladder01.news.aol.com>#1/1


>What is the best way to define a database column to store a year, without
>months or days? I want to store just the 4 digit year (e.g. 1998, 2001).
>
>
Define the column as a DATE datatype in the table, but put a trigger on the table that uses the TRUNC to only set the year. I know this works to save just the date; it should work for just the year also. Look up what the code is to truncate to the year;the code in your trigger should be something like this:

(column my_date is a DATE)
:new.my_date := trunc(:new.my_date,'YYYY');

Dan Received on Thu Mar 26 1998 - 00:00:00 CET

Original text of this message