Results 1 to 7 of 7
  1. #1
    leejqs is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    8

    Time Elapsed Problem

    I am trying to set up a "time elapsed" field in my report. I want the report to calculate the number of days passed from the initial contact date, to the closing date, which I have in respective fields. However, if the closing date is null, I want the time elapsed from initial contact date to TODAY's date calculated.

    So far I have =DateDiff("d",[Initial Contact],Date()) for when the date closed field is null.. and ,=DateDiff("d",[Initial Contact],[Date Closed]) to calculate from initial date to closed date. But I'm not sure how to merge these two into a single code.. any suggestions??

    Thanks!

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    So you need to use IIF(IsNull([Date Closed]),...IsNull,...IsNotNull)
    ...using your DateDiff() functions in the proper place.

  3. #3
    leejqs is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    8

    Problem

    =IIf(IsNull([Date Closed]),DateDiff("d",[Initial Contact],Date())), Iif(IsNotNull([Date Closed]),DateDiff("d",[Initial Contact],[Date Closed]))

    It's showing an invalid syntax message. I'm not quite sure what's wrong..

  4. #4
    leejqs is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    8

    Fix, Kind of

    I've changed it to =IIf(IsNull([Date Closed]),DateDiff("d",[Initial Contact],Date()),IIf(IsNotNull([Date Closed]),DateDiff("d",[Initial Contact],[Date Closed]))) ... it shows enter parameter IsNotNull but if I just click "ok" the message goes away and the field works just as I want.

  5. #5
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Try:
    =IIf(IsNull([Date Closed]),DateDiff("d",[Initial Contact],Date()),DateDiff("d",[Initial Contact],[Date Closed]))

  6. #6
    leejqs is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2009
    Posts
    8

    Perfect

    That worked perfectly, thanks a lot!!

  7. #7
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You're very welcome. Glad we could help.

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

Similar Threads

  1. query problem i have a problem wi
    By maxx3 in forum Queries
    Replies: 0
    Last Post: 06-29-2009, 02:29 AM
  2. problem in splitting Date and time fields
    By swaroop1012 in forum Queries
    Replies: 1
    Last Post: 11-22-2008, 11:29 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