Results 1 to 4 of 4
  1. #1
    Join Date
    May 2006
    Posts
    28

    Unanswered: Need help with an expression

    I'm having problems with an expression I'm trying to make:

    I have two date fields: date1 and date2

    What I want the expression to do is add 5 days to date1 but if that is null, then add it to date2. What I did but didn't work is
    Code:
    DateDue: [date1]+5 Or [date2]+5
    It works when I do it individually in two different fields but I don't want them in separate fields. Does anyone know what I'm doing wrong?

  2. #2
    Join Date
    Jun 2005
    Location
    Richmond, Virginia USA
    Posts
    2,763
    Provided Answers: 19
    This should do it:

    Code:
    If Isnull(date1) Then
    
         DateDue = DateAdd("d", 5,date2)
    
    Else 
    
         DateDue = DateAdd("d", 5,date1)
    
    End If
    Hope this helps!

    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  3. #3
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Provided Answers: 1
    DateDue: DateAdd("d", 5, nz([date1], [date2]))
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  4. #4
    Join Date
    May 2006
    Posts
    28
    Thanks for your replies - that worked Teddy!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •