Results 1 to 5 of 5
  1. #1
    KBrandon is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2011
    Posts
    2

    Calculating days between two dates, even when one is blank


    On my Access Form, I have two dates [StartDate], [EndDate] and another field [NoDays] that calculates the number of days between my two dates. Using DateDiff my calculation works fine, however, if I do not have an [EndDate] I want it to calculate from the [startDate] to today's date. How do I make this work?

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 7 64bit Access 2010 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Use an IIF statement and Test the date with IsDate().

  3. #3
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    Go to the Properties of NoDays and type this into the Control Source:
    Code:
     
    =IIf(IsNull([EndDate]),Date()-[StartDate],[EndDate]-[StartDate])

  4. #4
    KBrandon is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Sep 2011
    Posts
    2

    Talking Thanks!

    Quote Originally Posted by Robeen View Post
    Go to the Properties of NoDays and type this into the Control Source:
    Code:
     
    =IIf(IsNull([EndDate]),Date()-[StartDate],[EndDate]-[StartDate])

    Thanks!! It worked perfectly....YOU ROCK!!

  5. #5
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I'm happy that I could help. All the best!

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

Similar Threads

  1. Select Dates between days and two days ago?
    By rstonehouse in forum Queries
    Replies: 4
    Last Post: 08-18-2010, 02:13 AM
  2. Calculating Dates
    By TC0126 in forum Queries
    Replies: 1
    Last Post: 02-23-2010, 08:13 PM
  3. Replies: 4
    Last Post: 08-27-2009, 01:21 AM
  4. Calculating Dates
    By AJ0424 in forum Programming
    Replies: 1
    Last Post: 07-14-2009, 08:29 AM
  5. calculating due dates in access
    By trixxnixon in forum Forms
    Replies: 0
    Last Post: 09-28-2008, 12:35 PM

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