Results 1 to 4 of 4
  1. #1
    leslina76 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    5

    Need help Modifying a query expression

    I have a query expression that shows me how many months are left on all our company loans. It works great, however I need to modify it where (if the loan end date is in the past to just show 0). I could easily do this in excel by have no clue in Access. My query does show 0 if my loan end date is 04/01/2010 to date() "today" but once the month changes to June 2011 it will show -1, July it will show, -2 so on so on. So my only issue is telling it that anything less than 0 should always stay at 0. These negatives are screwing up my calculations. It seems to simple yet I'm stumpted. HELP!

    Current expression below:
    Months Left: DateDiff("m",Date(),[loan end date])

  2. #2
    ssanfu is offline Master of Nothing
    Windows 2K Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Here are 3 different ways to force a negative number to zero:

    1) Months Left: IIf(DateDiff("m",Date(),[loan end date])>0 ,DateDiff("m",Date(),[loan end date]),0)


    2) Months Left: DateDiff("m",Date(),[loan end date]) * ABS((DateDiff("m",Date(),[loan end date])>0))


    3) Months Left: DateDiff("m",Date(),[loan end date]) * (DateDiff("m",Date(),[loan end date])>0) * -1

  3. #3
    leslina76 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    5

    Query issue

    Great! Thanks. I'll give it a try and post the results. Thanks for taking the time to help me. I really appreciate it.

  4. #4
    leslina76 is offline Novice
    Windows XP Access 2007
    Join Date
    Apr 2011
    Posts
    5

    Solved

    It worked, thanks so much!

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

Similar Threads

  1. Update Query: Modifying Data Using Top Values
    By William McKinley in forum Queries
    Replies: 1
    Last Post: 11-30-2010, 02:20 PM
  2. Query using IIf(IsNull) expression
    By jmartin in forum Queries
    Replies: 3
    Last Post: 12-18-2009, 04:19 PM
  3. Sum problem for query expression
    By Stanggirlie in forum Access
    Replies: 3
    Last Post: 09-18-2009, 05:54 AM
  4. Modifying Update Query
    By James Elvin in forum Queries
    Replies: 0
    Last Post: 10-14-2008, 09:07 AM
  5. Query expression for form
    By pjacob in forum Forms
    Replies: 1
    Last Post: 10-10-2006, 09:12 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