+ Reply to Thread
Results 1 to 7 of 7

Calculate Days in a Month

  1. #1
    LGG
    Guest

    Calculate Days in a Month

    Hi. I need help finding a formula to calculate the number of days in a month
    depending on the month you choose from a drop down menu.
    Example:

    In cell A1 user will be ask to select a month from a drop down menu.
    In cell B1 I want the number of days in the month corresponding to the month
    selected in A1. So, if February is chosen on A1, then 28 (days) would appear
    on B1.

    I was trying to do if statements, but I keep getting an error. Is there an
    easy way to do this?

    Thanks
    LGG

  2. #2
    Biff
    Guest

    Re: Calculate Days in a Month

    Hi!

    > if February is chosen on A1, then 28 (days) would appear


    What about leap years when Feb has 29 days?

    One way:

    In some location list the months:

    J1 = January
    J2 = February
    J3 = March
    ...
    J12 = December

    =DAY(DATE(YEAR(TODAY()),MATCH(A1,J1:J12,0)+1,0))

    Biff

    "LGG" <[email protected]> wrote in message
    news:[email protected]...
    > Hi. I need help finding a formula to calculate the number of days in a
    > month
    > depending on the month you choose from a drop down menu.
    > Example:
    >
    > In cell A1 user will be ask to select a month from a drop down menu.
    > In cell B1 I want the number of days in the month corresponding to the
    > month
    > selected in A1. So, if February is chosen on A1, then 28 (days) would
    > appear
    > on B1.
    >
    > I was trying to do if statements, but I keep getting an error. Is there an
    > easy way to do this?
    >
    > Thanks
    > LGG




  3. #3
    Registered User
    Join Date
    11-13-2005
    Location
    Moscow
    Posts
    41

    Days in a Month?

    Hello LGG

    Well the easist way that I know to count the days in a month
    =DAY(EOMONTH($A$1;0)) but as for the Leap Year I am not 100% sure.

    I hope this is of help to you.


    Paul Maynard

  4. #4
    Arvi Laanemets
    Guest

    Re: Calculate Days in a Month

    Hi

    Add a sheet Months.
    Months!A1="Month"
    Months!A2=01.01.2006
    (or any other 1st of month in any valid date format)
    Months!A3=01.02.2006
    Select the range Months!A2:A3, and format in some valid date format like
    "mmmm yyyy" or "yyyy.mmmm".
    Copy the range down for some reasonable amount of rows - you get a list of
    months to be selected.

    Select the list of months, and define it as a named range Months. Hide sheet
    Months.

    On your entry sheet, apply to some cell (p.e. B1) a data validation list
    with Source=Months, and format the cell like month list on sheet Months.
    Into another cell, enter the formula:
    =IF($B$="","",DAY(DATE(YEAR($B$1),MONTH($B$1)+1,0)))
    ,or, with Analysis Toolpack Ad-In activated
    =IF($B$="","",DAY(EOMONTH($B$1,0)))


    --
    Arvi Laanemets
    ( My real mail address: arvi.laanemets<at>tarkon.ee )


    "LGG" <[email protected]> wrote in message
    news:[email protected]...
    > Hi. I need help finding a formula to calculate the number of days in a
    > month
    > depending on the month you choose from a drop down menu.
    > Example:
    >
    > In cell A1 user will be ask to select a month from a drop down menu.
    > In cell B1 I want the number of days in the month corresponding to the
    > month
    > selected in A1. So, if February is chosen on A1, then 28 (days) would
    > appear
    > on B1.
    >
    > I was trying to do if statements, but I keep getting an error. Is there an
    > easy way to do this?
    >
    > Thanks
    > LGG




  5. #5
    Ron Rosenfeld
    Guest

    Re: Calculate Days in a Month

    On Thu, 12 Jan 2006 22:30:02 -0800, LGG <[email protected]> wrote:

    >Hi. I need help finding a formula to calculate the number of days in a month
    >depending on the month you choose from a drop down menu.
    >Example:
    >
    >In cell A1 user will be ask to select a month from a drop down menu.
    >In cell B1 I want the number of days in the month corresponding to the month
    >selected in A1. So, if February is chosen on A1, then 28 (days) would appear
    >on B1.
    >
    >I was trying to do if statements, but I keep getting an error. Is there an
    >easy way to do this?
    >
    >Thanks
    >LGG


    To check the days of the month, I assumed that

    1. The month you are choosing is from a list of text strings, and not real
    Excel dates formatted to show just the month.

    2. The year is "this" year, so February will only show 29 days if "this" year
    is a leap year.

    B1:

    =DAY((A1&YEAR(TODAY()))+32-DAY((A1&YEAR(TODAY()))+32))


    --ron

  6. #6
    TomHinkle
    Guest

    RE: Calculate Days in a Month

    Easy.... One line....
    ASSUMING the value in A1 is a date


    in B1:
    =Date(year(a1),month(a1)+1,1))- Date(year(a1),month(a1),1))


    "LGG" wrote:

    > Hi. I need help finding a formula to calculate the number of days in a month
    > depending on the month you choose from a drop down menu.
    > Example:
    >
    > In cell A1 user will be ask to select a month from a drop down menu.
    > In cell B1 I want the number of days in the month corresponding to the month
    > selected in A1. So, if February is chosen on A1, then 28 (days) would appear
    > on B1.
    >
    > I was trying to do if statements, but I keep getting an error. Is there an
    > easy way to do this?
    >
    > Thanks
    > LGG


  7. #7
    LGG
    Guest

    Re: Calculate Days in a Month

    Thanks Biff! This was really helpful. It works!!! You saved my work.
    LGG

    "Biff" wrote:

    > Hi!
    >
    > > if February is chosen on A1, then 28 (days) would appear

    >
    > What about leap years when Feb has 29 days?
    >
    > One way:
    >
    > In some location list the months:
    >
    > J1 = January
    > J2 = February
    > J3 = March
    > ...
    > J12 = December
    >
    > =DAY(DATE(YEAR(TODAY()),MATCH(A1,J1:J12,0)+1,0))
    >
    > Biff
    >
    > "LGG" <[email protected]> wrote in message
    > news:[email protected]...
    > > Hi. I need help finding a formula to calculate the number of days in a
    > > month
    > > depending on the month you choose from a drop down menu.
    > > Example:
    > >
    > > In cell A1 user will be ask to select a month from a drop down menu.
    > > In cell B1 I want the number of days in the month corresponding to the
    > > month
    > > selected in A1. So, if February is chosen on A1, then 28 (days) would
    > > appear
    > > on B1.
    > >
    > > I was trying to do if statements, but I keep getting an error. Is there an
    > > easy way to do this?
    > >
    > > Thanks
    > > LGG

    >
    >
    >


+ 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