Results 1 to 7 of 7
  1. #1
    vgsdrm2020 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2015
    Posts
    3

    Calculating Elapsed Time in the Table Fields

    Good Morning: I have been trying for about 8 hours to calculate elapsed time between two fields into a third field in Access 2007. Unfortunately, the expression
    IIf(IsNull)([Final Suspense]),DateDiff("d",[Routing Status Date],Date()),DateDiff("d",[Routing Status Date],[Final Suspense]))
    is not working. Image enclosed.Click image for larger version. 

Name:	Access_Calculated.JPG 
Views:	11 
Size:	46.4 KB 
ID:	21212


    I need to know how to do this correctly by this afternoon, so I apologize for the flail. I have two products I must produce by 1300. I appreciate the help!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,550
    dont other with the IF and the ISNULL in the function.
    in the query set the criteria in the [FINAL SUSPENSE] field where NOT IS NULL.
    this removes any nulls.

    so the field will now be DATEDIFF("d",[FINAL SUSPENSE],date())

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    It seems you are using Calculated fields in the table. This is probably the issue. Maybe you can create some code behind a form and collect the info from the calculated field into a Variable. Then you can use the variable for your IIF or If Then Else ...

  4. #4
    vgsdrm2020 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2015
    Posts
    3
    I'm sorry, I am on a work computer and have limited coding capability
    OK: so get the difference between my routing status date and final suspense, I do use the formula in a calculated field? I'm not trying to create a form, but if I have to? I want to see my results on my table so I can export to Excel when done.

  5. #5
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    It seems simple enough. You need the difference between two dates. The question is where are these two dates? Where is Routing Status Date and where is Final Suspense?

    I ask, where, because if one of these is a calculated field, it complicates things. Can you provide the table name(s) and field data types for these two fields. If one is a calculated field, how and where is it getting its raw data from? What are the types, names, etc.

  6. #6
    vgsdrm2020 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jul 2015
    Posts
    3
    Except for what I am trying to do, all data is entered manually by me (Yes I choose the date and format) but routing status date and final suspense are just dates. Table name is OI Index
    So no, none are calculated

  7. #7
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    OK, I think I understand. What you can do is create an alias in a query. Start new. Create a new query for testing. Add your two date fields. Then, create an alias. The following syntax should work, you just need to use this syntax with a new alias.
    Code:
    IIf(IsNull([Final Suspense]), DateDiff("d", [Routing Status Date], Date()), DateDiff("d", [Routing Status Date], [Final Suspense]))
    To create a new alias type a name for your alias in a new filed in the design grid at the bottom of your query designer. So to the right of Final Suspense, for instance, type MyAlias:

    Right after the colon of your alias, paste the IIf statement.

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

Similar Threads

  1. Calculating elapsed time over a 24 hour period
    By kcmiuser in forum Queries
    Replies: 3
    Last Post: 08-11-2014, 11:47 AM
  2. Replies: 5
    Last Post: 10-22-2013, 01:00 PM
  3. calculating time fields
    By donnan33 in forum Programming
    Replies: 5
    Last Post: 01-19-2012, 12:15 PM
  4. HELP With Elapsed Time in Form
    By accessineedhelp in forum Forms
    Replies: 6
    Last Post: 09-01-2011, 10:30 AM
  5. Calculating Elapsed Time
    By jo15765 in forum Forms
    Replies: 8
    Last Post: 04-15-2011, 07:00 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