Results 1 to 5 of 5
  1. #1
    2 Star Lounger
    Join Date
    Jul 2006
    Location
    Bangalore, India
    Posts
    180
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Capture Month for Reporting (Excel 2003)

    Hi Excel Experts,

    In our organisation, all our monthly reports are from 26th of current month 25th of subsequent month. I have created a formula to pick the month based on the same. However i have a small problem with the same when there are months with 31 and 30 days.

    =TEXT(IF(DAY($L2)<26,DATE(YEAR($L2),MONTH($L2),DAY ($L2)),DATE(YEAR($L2),MONTH($L2)+1,DAY($L2))),"mmm m-yy")

    In the above formula if the date is 31st-Oct then the month comes as December and not November since there are only 30 days in nov. is there a way to fix this.

    Regards
    Baiju

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Lewes, East Sussex, Sussex, United Kingdom
    Posts
    232
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Capture Month for Reporting (Excel 2003)

    Baiju

    I think if you replace the DAY($L2) with 1 in the formula it should work correctly.

    Nick

  3. #3
    WS Lounge VIP sdckapr's Avatar
    Join Date
    Jul 2002
    Location
    Pittsburgh, Pennsylvania, USA
    Posts
    11,225
    Thanks
    14
    Thanked 342 Times in 335 Posts

    Re: Capture Month for Reporting (Excel 2003)

    Since you are not putting the day down, how about:
    =TEXT(IF(DAY($L2)<26,DATE(YEAR($L2),MONTH($L2),DAY ($L2)),DATE(YEAR($L2),MONTH($L2)+1,1)),"mmmm-yy")

    You move an extra month since if the next month does not have 31 days, it goes to the next month. If the date is Oct 31, then your formula wants the Month/year for "november 31" = Dec 1 since nov has only 30 days. If you just use the 1st you don't ever "turn over" the month.

    Steve

  4. #4
    2 Star Lounger
    Join Date
    Jul 2006
    Location
    Bangalore, India
    Posts
    180
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Capture Month for Reporting (Excel 2003)

    Thanks Steve & Nick its working fine now.

  5. #5
    WS Lounge VIP rory's Avatar
    Join Date
    Dec 2000
    Location
    Burwash, East Sussex, United Kingdom
    Posts
    6,280
    Thanks
    3
    Thanked 191 Times in 177 Posts

    Re: Capture Month for Reporting (Excel 2003)

    Just as an alternative version:
    <code>=TEXT(DATE(YEAR($L2),MONTH($L2)+(DAY($L2)>25 ),1),"mmmm-yy")</code>
    FWIW.
    Regards,
    Rory

    Microsoft MVP - Excel

Posting Permissions

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