+ Reply to Thread
Results 1 to 6 of 6

Adding different period units to a date.

  1. #1
    Forum Contributor
    Join Date
    05-14-2015
    Location
    West Yorkshire
    MS-Off Ver
    10
    Posts
    130

    Adding different period units to a date.

    Hi, is there a formula for adding different periods to a date depending on what unit is selected from a drop down menu (days,weeks,months,years).

    I can only find EDATE that works great but for months only... I've attached a file to show what I'm trying to achieve.

    As always any help would be greatly appreciated
    Attached Files Attached Files

  2. #2
    Forum Moderator AliGW's Avatar
    Join Date
    08-10-2013
    Location
    Retired in Ipswich, Suffolk, but grew up in Sawley, Derbyshire (England)
    MS-Off Ver
    MS 365 Subscription Insider Beta Channel v. 2404 (Windows 11 22H2 64-bit)
    Posts
    80,830

    Re: Adding different period units to a date.

    Great! the only example you've given is ... Wait for it ... MONTHS!!!

    Maybe try adding a few more lines of data that actually show the isuue you want help with??? Thanks.
    Ali


    Enthusiastic self-taught user of MS Excel who's always learning!
    Don't forget to say "thank you" in your thread to anyone who has offered you help.
    You can reward them by clicking on * Add Reputation below their user name on the left, if you wish.

    Forum Rules (updated August 2023): please read them here.

  3. #3
    Forum Contributor
    Join Date
    05-14-2015
    Location
    West Yorkshire
    MS-Off Ver
    10
    Posts
    130

    Re: Adding different period units to a date.

    Hi, I'm really sorry if I've not given enough information. The formula just needs to calculate the new date if it was 6 days, 6 weeks, 6 months, or 6 years...

  4. #4
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,827

    Re: Adding different period units to a date.

    I don't think there is a single function that will do this, but it should be possible to piece together appropriate logic that will be able to do this. Here's the logic I see:

    1) For months, the formula you have works just fine.
    2) Years can be treated the same as months, but mutliply the value in F7 by 12 (there are 12 months in a year). EDATE(D7,F7*IF(H7="YEARS",12,1)) should be able to handle the months and years options.
    3) Excels calendar system is based on days, so the option of days should be as simple as adding D7 and F7 D7+F7
    4) There are 7 days in a week, so something similar to the months/years pairing should work for days D7+F7*IF(H7="WEEKS",7,1)
    5) Now we just need some way to have Excel test for "DAYS/WEEKS" or "YEARS/MONTHS". =IF(OR(H7="DAYS",H7="WEEKS"),D7+...,EDATE(...))

    There are certainly other ways to do it, but that should work.
    Quote Originally Posted by shg
    Mathematics is the native language of the natural world. Just trying to become literate.

  5. #5
    Forum Contributor
    Join Date
    05-14-2015
    Location
    West Yorkshire
    MS-Off Ver
    10
    Posts
    130

    Re: Adding different period units to a date.

    Thanks for the help Mr Shorty!

    From your reply I've constructed the following formula for cell "J7". It would be great if someone could improve on this...

    Formula: copy to clipboard
    Please Login or Register  to view this content.


    Thanks again.

  6. #6
    Forum Guru
    Join Date
    04-13-2005
    Location
    North America
    MS-Off Ver
    2002/XP and 2007
    Posts
    15,827

    Re: Adding different period units to a date.

    Your formula looks fine. I notice that it is checking if H7="MONTHS" twice, and I don't see a reason for checking twice, but I don't expect it to create a problem.

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. adding units column to pivot table
    By mujofifty in forum Excel Charting & Pivots
    Replies: 2
    Last Post: 04-08-2015, 06:23 AM
  2. Replies: 3
    Last Post: 11-13-2014, 03:32 PM
  3. [SOLVED] Semi Monthly autofill Period Starting Date based on Period Ending Date
    By greatwent in forum Excel General
    Replies: 6
    Last Post: 01-30-2014, 03:29 AM
  4. [SOLVED] Adding date and period
    By thilag in forum Excel Formulas & Functions
    Replies: 3
    Last Post: 01-27-2013, 09:28 AM
  5. [SOLVED] Complicated:Calculate time period based on no. of units sold + fluctuations within period
    By omaha.crab in forum Excel Formulas & Functions
    Replies: 2
    Last Post: 09-06-2012, 03:04 AM
  6. Adding units of time in 2007
    By jimcpenrodjr in forum Excel General
    Replies: 1
    Last Post: 06-04-2010, 02:35 AM
  7. Adding the units ordered for each unique seller
    By McDimwitty in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-25-2007, 04:59 PM

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