Why won't date formula work?
Thanks Thanks:  0
Likes Likes:  0
Results 1 to 8 of 8

Thread: Why won't date formula work?

  1. #1
    Board Regular
    Join Date
    Feb 2002
    Location
    Clovis, NM
    Posts
    334
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

     
    This formula in A1 properly displays 2004

    =YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC(((DATE(Base,12,31))-$AI$2)/365),YEARS)),SICK)+1),SICK,0))

    This formula in A2 properly displays 01-01-04

    =DATE(A1,1,1)

    When I replace A1 in the formula above with the actual formula from A1, I get an error with DATE just after ((( highlighted. Why won't this work?

    =DATE((YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC(((DATE(Base,12,31))-$AI$2)/365),YEARS)),SICK)+1),SICK,0))),1,1)

  2. #2
    MrExcel MVP
    Join Date
    Mar 2002
    Location
    Michigan USA
    Posts
    11,454
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-29 06:43, pilot wrote:
    This formula in A1 properly displays 2004

    =YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC(((DATE(Base,12,31))-$AI$2)/365),YEARS)),SICK)+1),SICK,0))

    This formula in A2 properly displays 01-01-04

    =DATE(A1,1,1)

    When I replace A1 in the formula above with the actual formula from A1, I get an error with DATE just after ((( highlighted. Why won't this work?

    =DATE((YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC(((DATE(Base,12,31))-$AI$2)/365),YEARS)),SICK)+1),SICK,0))),1,1)
    Hi Pilot:
    If your formula for the year in A1 works OK, then a cursory look at your formula in A2, shows you have an extra left parentheses ...
    so replace the formual in A2 with

    =DATE(YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC(((DATE(Base,12,31))-$AI$2)/365),YEARS)),SICK)+1),SICK,0))),1,1)

    I have not cheked this formula ... but give it a shot.

    Please post back if it works for you ... otherwise explain a little further and let us take it from there!




    _________________
    Yogi Anand

    Edit: Deleted inactive website from hardcoded signature

    [ This Message was edited by: Yogi Anand on 2003-01-19 14:19 ]

  3. #3
    Board Regular
    Join Date
    Feb 2002
    Location
    Clovis, NM
    Posts
    334
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    The formula in A2 works and I count the net parentheses as zero. In your suggestion, I count one extra right paren. It's gotta be something else. Thanks for all help.

  4. #4
    MrExcel MVP Aladin Akyurek's Avatar
    Join Date
    Feb 2002
    Location
    The Hague, NL
    Posts
    81,772
    Post Thanks / Like
    Mentioned
    11 Post(s)
    Tagged
    1 Thread(s)

    Default

    On 2002-03-29 07:07, pilot wrote:
    The formula in A2 works and I count the net parentheses as zero. In your suggestion, I count one extra right paren. It's gotta be something else. Thanks for all help.
    That's right, I mean, your hypothesis. I'd like to have a look at the WB itself, if possible.

    Aladin

  5. #5
    MrExcel MVP
    Join Date
    Mar 2002
    Location
    Michigan USA
    Posts
    11,454
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    On 2002-03-29 07:07, pilot wrote:
    The formula in A2 works and I count the net parentheses as zero. In your suggestion, I count one extra right paren. It's gotta be something else. Thanks for all help.
    Hi Pilot:
    Some times it is so difficult to check -- especially one's own work. If you like you can email your workbook to me and I will be glad to look at where the problem might be.
    Regards!

    Yogi Anand, D.Eng, P.E.
    Energy Efficient Building Network LLC
    www.energyefficientbuild.com

  6. #6
    MrExcel MVP
    Join Date
    Mar 2002
    Location
    Michigan USA
    Posts
    11,454
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

    Hi Jim:
    I did get you workbook -- I did analyze it. The problem was that in using the year calculation in the date formula you exceeded the limit of 7 levels of nested functions. It is surprising that Excel will not point this out but consider this an error. Solution -- use the results of your year calculation in another formula so you don't exceed the limit of nested functions.

    Please post back if it works for you ... otherwise explain alittle further and let us take it from there!
    Regards!

    Yogi Anand, D.Eng, P.E.
    Energy Efficient Building Network LLC
    www.energyefficientbuild.com

  7. #7
    MrExcel MVP Aladin Akyurek's Avatar
    Join Date
    Feb 2002
    Location
    The Hague, NL
    Posts
    81,772
    Post Thanks / Like
    Mentioned
    11 Post(s)
    Tagged
    1 Thread(s)

    Default


    This formula in A1 properly displays 2004

    =YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC(((DATE(Base,12,31))-$AI$2)/365),YEARS)),SICK)+1),SICK,0))

    This formula in A2 properly displays 01-01-04

    =DATE(A1,1,1)

    When I replace A1 in the formula above with the actual formula from A1, I get an error with DATE just after ((( highlighted. Why won't this work?

    =DATE((YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC(((DATE(Base,12,31))-$AI$2)/365),YEARS)),SICK)+1),SICK,0))),1,1)


    Pilot,

    I see you already got a reply as to the nature of the problem: Wrapping the first working formula within an additional function causes to exceed a built-in limit in Excel. One solution is what Yogi suggested, another for which I opted is:

    =DATE(YEAR($AI$2)+INDEX(YEARS,MATCH(INDEX(SICK,MATCH(INDEX(SICK,MATCH(TRUNC((BaseDate-$AI$2)/365),YEARS)),SICK)+1),SICK,0)),1,1)

    where BaseDate is a named formula consisting of:

    [A]

    =DATE(Base,12,31)

    If this solution sounds good to you,

    activate Insert|Name|Define,
    enter BaseDate (or something more intelligible) as name in the Names in Workbook box, and
    enter [A] as formula in the Refers to box.

    Aladin

    [ This Message was edited by: Aladin Akyurek on 2002-03-29 11:20 ]

  8. #8
    Board Regular
    Join Date
    Feb 2002
    Location
    Clovis, NM
    Posts
    334
    Post Thanks / Like
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Default

      
    Thanks Yogi and Aladin, it works like a charm. I like the limitation workaround that Aladin suggested - and I learned something new and quite useful, too. This is a great resource!!!

User Tag List

Like this thread? Share it with others

Like this thread? Share it with others

Posting Permissions

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

 

 
DMCA.com