If DateSold is null then use Date() in workday function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • fin2012
    New Member
    • Oct 2015
    • 3

    If DateSold is null then use Date() in workday function

    I have two query expressions which works separately:
    Days1:
    Code:
    IIf(IsNull([DateSold]),Date()-[DateBuy],Workdays([DateBuy],[DateSold]))
    Day4:
    Code:
    Workdays([DateBuy],Date())
    but when combined it does not work - too many arguments:

    Days5:
    Code:
    IIf((IsNull([DateSold]),Workdays([DateBuy],Date()),Workdays([DateBuy],[DateSold])))
    what is the solution please?
    Last edited by zmbd; Nov 5 '15, 06:23 AM. Reason: [z{placed code format}]
  • Rabbit
    Recognized Expert MVP
    • Jan 2007
    • 12517

    #2
    You have an extra set of outside parentheses on your Days5 expression.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32634

      #3
      As Rabbit says, it should be :
      Code:
      Days5: IIf(IsNull([DateSold]),Workdays([DateBuy],Date()),Workdays([DateBuy],[DateSold]))
      An alternative approach might be :
      Code:
      Days5: Workdays([DateBuy],Nz([DateSold],Date()))

      Comment

      • fin2012
        New Member
        • Oct 2015
        • 3

        #4
        Thank you Rabbit for the solution.

        Comment

        • fin2012
          New Member
          • Oct 2015
          • 3

          #5
          I like the Nz suggestion, much neater. Thanks for that NeoPa.

          Comment

          • NeoPa
            Recognized Expert Moderator MVP
            • Oct 2006
            • 32634

            #6
            My pleasure Fin :-)

            Comment

            Working...