Results 1 to 4 of 4
  1. #1
    RICH48 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    2

    Red face calculating date diff in query or sql

    hoping someone can help... I'm trying to work out the difference between 2 records both of which have a call out date [bas start date]..
    basically the structure is

    equipment number call number bas start date
    12345678 112255 1/7/14
    12345678 112256 3/7/14

    What i'm after is the 4th column to work out the date diff... in this case 2 days
    the equipment can be multiple times so i might see equipment number 12345678 - upto 10 times with consecutive dates - all of which i need to know the difference between the current call date and the previous call date..

    hope this is clear for someone to help out :-)

    I've been using access for some time now so not a beginner... or thought i wasn't..... so appreciate any help so i can sleep tonight...



    cheers rich48
    Last edited by RICH48; 07-29-2014 at 07:15 AM. Reason: subject wasnt clear

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,524
    dateDiff("D",[START DATE],[END DATE]) 'if you have an end date
    OR
    dateDiff("D",[START DATE],DATE()) 'up to today

  3. #3
    RICH48 is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Jul 2014
    Posts
    2
    Hi Ranman yeah tried that but not exactly what i need....

    Click image for larger version. 

Name:	Capture.PNG 
Views:	12 
Size:	11.7 KB 
ID:	17542

    basically we have to work out the number of days between the 2 dates - and i could have like 1 say 20 entries all with dates...
    need to calculate the no of days between them all...
    so
    call 1-2
    call 2-3
    call 3-4 and so on...

    that help.??

    rich48

  4. #4
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    Hi -

    That is not something you can do with a query or SQL. Access is not good at making comparisons between records in the way Excel can. Essentially, Access only "knows" about the current record.

    What you want to do will require VBA code to step through the records for a specified "equipment number", in the proper order.

    John

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

Similar Threads

  1. Date diff on Forum
    By Auto in forum Forms
    Replies: 5
    Last Post: 11-20-2013, 11:00 PM
  2. Replies: 1
    Last Post: 02-24-2013, 09:30 PM
  3. Replies: 12
    Last Post: 04-26-2012, 04:01 AM
  4. Replies: 1
    Last Post: 01-26-2012, 10:22 PM
  5. Date diff trouble
    By Cran29 in forum Queries
    Replies: 3
    Last Post: 03-11-2011, 01:02 PM

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