Results 1 to 3 of 3
  1. #1
    latifju is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    6

    Difference between two date in same column of two consecutive raw

    I am new in access 2010. for my official work I need to build a report but I can't cause I don't know how to do that. My table like below



    ID startDate Dr Cr
    1 12-JAN-12 12,000 0
    2 13-JAN-12 50,000 2,500
    3 15-JAN-12 1,00,000 50,000
    4 16-JAN-12 25,000 30,000

    I want my report or query like bilow


    ID startDate Dr Cr Dr_Cr DateDiff Product
    1 12-JAN-12 12,000 0 12,000 1 12,000
    2 13-JAN-12 50,000 2,500 47,500 2 95,000
    3 15-JAN-12 1,00,000 50,000 50,000 1 50,000
    4 16-JAN-12 25,000 30,000
    -5,000 0 0

    The red column is the problem for me in query. What can I do for the red colum. If I can do it in query it will be very short proccess or I have to leave this access report. Please some help me to find out the solution for the problem.

    Thanks for your help
    Abdul Latif
    Bangladesh

  2. #2
    alansidman's Avatar
    alansidman is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Apr 2010
    Location
    Steamboat Springs
    Posts
    2,529
    Try this:

    Code:
    SELECT table1.Id, table1.StartDate, table1.Dr, table1.Cr, [Dr]-table1.Cr AS Dr_Cr, DLookUp("StartDate","table1","[ID]=" & [ID]+1) AS [Prior], NZ(DateDiff("d",[StartDate],[Prior]),0) AS Difference, [Dr_Cr]*[Difference] AS Product
    FROM table1;

  3. #3
    latifju is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jan 2013
    Posts
    6
    Thanks, Its works.... , One more problem if Raw 3 (means ID = 3) deleted than what will be?
    Last edited by latifju; 01-23-2013 at 01:24 PM. Reason: amendment

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 14
    Last Post: 09-11-2013, 01:10 PM
  2. Replies: 3
    Last Post: 09-19-2012, 08:59 AM
  3. Consecutive ID numbers
    By jdvd in forum Database Design
    Replies: 2
    Last Post: 12-11-2011, 06:48 PM
  4. Replies: 4
    Last Post: 10-18-2011, 03:46 PM
  5. Replies: 1
    Last Post: 04-15-2010, 02:07 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums