+ Reply to Thread
Results 1 to 3 of 3

Date in an IF statement

  1. #1
    LyndieBee
    Guest

    Date in an IF statement

    I'd like to be able to evaluate the current date and have the name of the
    previous month display in a cell. For example if I'm in cell A1 I want the
    statement to check today's date (March 8, 2005) and return last month's month
    "April". Can I accomplish this with an IF statement? Any other function?
    Many thanks, Lyndie

  2. #2
    JulieD
    Guest

    Re: Date in an IF statement

    Hi

    i would have thought that last month's month was Feburary and next month's
    month was April ... however, here's two options
    - returns Feburary
    =TEXT(EOMONTH(NOW(),-1),"mmmm")
    - returns April
    =TEXT(EOMONTH(NOW(),1),"mmmm")

    Note, to use the EOMONTH function you need to have the Analysis Tool-Pak
    add-in installed (tools / add-ins)

    Cheers
    JulieD

    "LyndieBee" <LyndieBee@discussions.microsoft.com> wrote in message
    news:1179091A-4A6A-48DE-9100-CEC65EF920C6@microsoft.com...
    > I'd like to be able to evaluate the current date and have the name of the
    > previous month display in a cell. For example if I'm in cell A1 I want
    > the
    > statement to check today's date (March 8, 2005) and return last month's
    > month
    > "April". Can I accomplish this with an IF statement? Any other function?
    > Many thanks, Lyndie




  3. #3
    Ron Rosenfeld
    Guest

    Re: Date in an IF statement

    On Tue, 8 Mar 2005 06:59:04 -0800, LyndieBee
    <LyndieBee@discussions.microsoft.com> wrote:

    >I'd like to be able to evaluate the current date and have the name of the
    >previous month display in a cell. For example if I'm in cell A1 I want the
    >statement to check today's date (March 8, 2005) and return last month's month
    >"April". Can I accomplish this with an IF statement? Any other function?
    >Many thanks, Lyndie


    To return the previous month,

    =TEXT(A1-DAY(A1),"mmmm")

    To return the name of the next month:

    =TEXT(A1-DAY(A1)+33-DAY(A1-DAY(A1)+32),"mmmm")

    Simpler might be to just compute a date in the month, and format the cell as
    "mmmm"

    Then the above formulas become:

    Previous month:

    A1-DAY(A1)

    Next month:

    A1-DAY(A1)+33-DAY(A1-DAY(A1)+32)


    --ron

+ 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