Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: date field subtraction problem
Frank Launer <Frank.Launer_at_draeger.com> wrote:
>Hi,
>
>I've a problem with subtracting two columns.
>
>For the subtraction I want to write a database-trigger.
>
> create table test(prod_date DATE, // YY-MON-YY
> vert_date NUMBER(6) // YYYYWW
> prod_ver_diff NUMBER(4));
>
>e.g. prod_date = '12-JAN-97'
>e.g. vert_date = 198050
>
>I want to have the number of weeks between the two "dates"
>
>( prod_date - vert_date = number of weeks ).
>
>I tried several algorithms without success.
>
>Who can help me?
>
>Database-Version Release 7.0.16.6.0
>
>-----------------------------------------------------------
>Frank Launer
>
Hi there,
Can you try using to_date on both the fields and then subtract. Then divide the resulted value by 7. I think the above should give you the desired output.
Regards
N.Prabhakar Received on Mon Feb 03 1997 - 00:00:00 CST
![]() |
![]() |