Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: date field subtraction problem

Re: date field subtraction problem

From: N Prabhakar <prabhs_at_po.pacific.net.sg>
Date: 1997/02/03
Message-ID: <5d4m9b$d9q$3@newton.pacific.net.sg>#1/1

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

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US