Home » SQL & PL/SQL » SQL & PL/SQL » How to calculating the difference between dates on different rows
How to calculating the difference between dates on different rows [message #18729] Tue, 12 February 2002 13:54 Go to next message
UmaSund
Messages: 22
Registered: February 2002
Junior Member
Hi

I have a set of rows returned by a query regarding a Job. One of the Columns is last_update date.The result is ordered by this date asc only.

Now, I need to Calculate the difference between row 2 date and row 1 date and display it for row 1, then difference bewteen row 3 and row 2 date and display it for row 2 and so on.

The numbers of rows which will be returned for a Job will vary. Some may return 3 others may return say 20.

Is this calculation possible using sql or pl/sql?

How can it be achieved.

Thanks in adavance.

Thanks
-UmaSund
Re: How to calculating the difference between dates on different rows [message #18733 is a reply to message #18729] Tue, 12 February 2002 18:39 Go to previous messageGo to next message
Somu
Messages: 24
Registered: February 2000
Junior Member
Hi,

You can do this in a PL/SQL.

The steps you can follow.

1. Declare the Cursor as it in the normal with your order condition.
2. Fetch the 1st record and store it into a memory
3. Fetch the 2nd record and store it into a memory
4. Find out the date difference between these two
records and display it in the report

if you need the sample, let me know..
Re: How to calculating the difference between dates on different rows [message #18753 is a reply to message #18729] Wed, 13 February 2002 06:12 Go to previous message
UmaSund
Messages: 22
Registered: February 2002
Junior Member
Hi Somu

A sample would be a great help.

Thanks
-UmaSund
Previous Topic: Figure out if it is the end of the month
Next Topic: steps after sucessfully created the cursor
Goto Forum:
  


Current Time: Thu Mar 28 14:28:00 CDT 2024