#1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5
Default Date Fomula Question

I need to figure out a formula that will add 30 days to a month/day/ date but
return the year as 2007 if the date is before 2007 and just add 30 days if
it's a date after the today format.

clear as mud, 'eh .... maybe this would be easier ... (see below)

ColumnA B
is: would need to return

3/15/2002 4/15/2007
3/18/1998 4/18/2007
3/20/2006 4/20/2007
3/21/2007 4/21/2007
6/28/2008 7/28/2008
4/1/2003 5/1/2007
4/1/2010 5/1/2010

and so on, the dates in column A vary, and I have no problem adding the
extra 30 days, but it's the year that's throwing me .... any suggestions?

Donna

  #2   Report Post  
Posted to microsoft.public.excel.misc
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Date Fomula Question

=date(if(year(A1+30)=2008,2006,2007),Month(A1),Day (A1)+30)

"rainbowraven" wrote:

I need to figure out a formula that will add 30 days to a month/day/ date but
return the year as 2007 if the date is before 2007 and just add 30 days if
it's a date after the today format.

clear as mud, 'eh .... maybe this would be easier ... (see below)

ColumnA B
is: would need to return

3/15/2002 4/15/2007
3/18/1998 4/18/2007
3/20/2006 4/20/2007
3/21/2007 4/21/2007
6/28/2008 7/28/2008
4/1/2003 5/1/2007
4/1/2010 5/1/2010

and so on, the dates in column A vary, and I have no problem adding the
extra 30 days, but it's the year that's throwing me .... any suggestions?

Donna

  #3   Report Post  
Posted to microsoft.public.excel.misc
bj bj is offline
external usenet poster
 
Posts: 1,397
Default Date Fomula Question

I should learn to read the whole message

=date(max(2007,year(A1),month(A1),day(A1)+30)

"bj" wrote:

=date(if(year(A1+30)=2008,2006,2007),Month(A1),Day (A1)+30)

"rainbowraven" wrote:

I need to figure out a formula that will add 30 days to a month/day/ date but
return the year as 2007 if the date is before 2007 and just add 30 days if
it's a date after the today format.

clear as mud, 'eh .... maybe this would be easier ... (see below)

ColumnA B
is: would need to return

3/15/2002 4/15/2007
3/18/1998 4/18/2007
3/20/2006 4/20/2007
3/21/2007 4/21/2007
6/28/2008 7/28/2008
4/1/2003 5/1/2007
4/1/2010 5/1/2010

and so on, the dates in column A vary, and I have no problem adding the
extra 30 days, but it's the year that's throwing me .... any suggestions?

Donna

  #4   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 964
Default Date Fomula Question

I'm not sure I understand correctly, but see if this works for you:

=IF(TODAY()A1,DATE(2007,MONTH(A1)+1,DAY(A1)),DATE (YEAR(A1),MONTH(A1),DAY(A1)+30))

HTH,
Elkar


"rainbowraven" wrote:

I need to figure out a formula that will add 30 days to a month/day/ date but
return the year as 2007 if the date is before 2007 and just add 30 days if
it's a date after the today format.

clear as mud, 'eh .... maybe this would be easier ... (see below)

ColumnA B
is: would need to return

3/15/2002 4/15/2007
3/18/1998 4/18/2007
3/20/2006 4/20/2007
3/21/2007 4/21/2007
6/28/2008 7/28/2008
4/1/2003 5/1/2007
4/1/2010 5/1/2010

and so on, the dates in column A vary, and I have no problem adding the
extra 30 days, but it's the year that's throwing me .... any suggestions?

Donna

  #5   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 5,651
Default Date Fomula Question

On Mon, 23 Apr 2007 12:50:00 -0700, rainbowraven
wrote:

I need to figure out a formula that will add 30 days to a month/day/ date but
return the year as 2007 if the date is before 2007 and just add 30 days if
it's a date after the today format.

clear as mud, 'eh .... maybe this would be easier ... (see below)

ColumnA B
is: would need to return

3/15/2002 4/15/2007
3/18/1998 4/18/2007
3/20/2006 4/20/2007
3/21/2007 4/21/2007
6/28/2008 7/28/2008
4/1/2003 5/1/2007
4/1/2010 5/1/2010

and so on, the dates in column A vary, and I have no problem adding the
extra 30 days, but it's the year that's throwing me .... any suggestions?

Donna


To add thirty days to some date in A6, and adjust so the result is not earlier
than 2007, use the formula:

=DATE(MAX(YEAR(A6),2007),MONTH(A6),DAY(A6)+30)

However, in your examples, you are NOT always adding 30 days. Sometimes you
are adding 31 days.

Perhaps what you want is:

=DATE(MAX(YEAR(A6),2007),MONTH(A6)+1,DAY(A6))-
(DAY(DATE(MAX(YEAR(A6),2007),MONTH(A6)+1,DAY(A6))) *
(DAY(DATE(MAX(YEAR(A6),2007),MONTH(A6)+1,DAY(A6))) <DAY(A6)))

All the stuff at the end is to adjust so that one month after Jan 31 will be
Feb 28 and not March 3.

Or if you have the Analysis Tool Pak installed, you could use:

=EDATE(DATE(MAX(YEAR(A6),2007),MONTH(A6),DAY(A6)), 1)






--ron


Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Fomula for number of days on each month from a date range [email protected] Excel Discussion (Misc queries) 3 November 9th 06 03:08 AM
Fomula (if?) Jules Excel Worksheet Functions 0 August 8th 06 07:13 PM
Fomula Steve Excel Discussion (Misc queries) 2 December 8th 05 07:29 PM
Please help, i need a fomula Age Formula?? Excel Worksheet Functions 2 October 13th 05 10:32 PM
IF Fomula DWadding Excel Discussion (Misc queries) 1 August 3rd 05 05:32 PM


All times are GMT +1. The time now is 09:52 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"