Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.tools -> Re: Storing yearless dates.
Brian Tkatch a écrit :
>
> I'm not doing this, though I am curious.
>
> Imagine I want to store the birthday of a list of people. But the year
> may not always be provided. How would I recognize whch dates had the
> years specified, and which not?
If you store these birthday in a date, Oracle always use a year (by default, the current year - or century - of the system date). In fact, in this example, if you're not sure of the year, just never use it ! To find out if today is the birthday of someone you can do something like this :
where to_char(birthday, 'DDMM') = to_char(sysdate, 'DDMM')
If you really don't care of the year, the best way is to store this "date" in char, varchar2 or number data, the usage is quite the same :
where birthday = to_char(sysdate, 'DDMM')
>
> Brian
-- Pierre CHARPENAYReceived on Fri Dec 01 2000 - 06:43:26 CST
![]() |
![]() |