+ Reply to Thread
Results 1 to 2 of 2

Matching the month and year portion of a date only

  1. #1
    RGB
    Guest

    Matching the month and year portion of a date only

    Hi,

    I have this formula which checks whether a date (G$1) is in a range and
    performs a bunch of actions based on whether it is or not.

    =IF(AND(G$1>=data!$K2, G$1<=data!$H2),
    (IF(TEXT(G$1,"yyyymm")=TEXT(data!$K2,"yyyymm"),$F2,data!$I2/data!$G2)),"")

    The second part starting (IF(TEXT(G$1, "yyymmm" etc is supposed to return a
    value ($F2) if the month and year part of G$1 and $K2 match. THis is not
    happening
    however and for F$2 to be pulled through the day part of the date has to
    match also.

    This is not supposed to happen! - i only want to match the month and year!

    Can anybody help?

  2. #2
    Elkar
    Guest

    RE: Matching the month and year portion of a date only

    Rather than using the TEXT function, try the MONTH and YEAR functions.

    =IF(AND(G$1>=data!$K2,G$1<=data!$H2),(IF(AND(MONTH(G$1)=MONTH(data!$K2),YEAR(G$1)=YEAR(data!$K2)),$F2,data!$I2/data!$G2)),"")

    HTH,
    Elkar


    "RGB" wrote:

    > Hi,
    >
    > I have this formula which checks whether a date (G$1) is in a range and
    > performs a bunch of actions based on whether it is or not.
    >
    > =IF(AND(G$1>=data!$K2, G$1<=data!$H2),
    > (IF(TEXT(G$1,"yyyymm")=TEXT(data!$K2,"yyyymm"),$F2,data!$I2/data!$G2)),"")
    >
    > The second part starting (IF(TEXT(G$1, "yyymmm" etc is supposed to return a
    > value ($F2) if the month and year part of G$1 and $K2 match. THis is not
    > happening
    > however and for F$2 to be pulled through the day part of the date has to
    > match also.
    >
    > This is not supposed to happen! - i only want to match the month and year!
    >
    > Can anybody help?


+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1