A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Excel » Worksheet Functions
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Same Date a year ago



 
 
Thread Tools Display Modes
  #1  
Old January 11th, 2010, 01:59 AM posted to microsoft.public.excel.worksheet.functions
Joe
external usenet poster
 
Posts: 1,218
Default Same Date a year ago

I am using

=DATE(YEAR(B2)-1,MONTH(B2)-0,1)

to return the same date for the previous year.

If B2 is 12/31/2009 it returns 12/1/2008 instead of 12/31/2008.

How do I get it to return 12/31/2008?
  #2  
Old January 11th, 2010, 02:33 AM posted to microsoft.public.excel.worksheet.functions
Rick Rothstein[_2_]
external usenet poster
 
Posts: 2,013
Default Same Date a year ago

You want this...

=DATE(YEAR(B2)-1,MONTH(B2),DAY(B2))

where you just subtract one from the year value and use the same month and
day values.

--
Rick (MVP - Excel)


"Joe" wrote in message
news
I am using

=DATE(YEAR(B2)-1,MONTH(B2)-0,1)

to return the same date for the previous year.

If B2 is 12/31/2009 it returns 12/1/2008 instead of 12/31/2008.

How do I get it to return 12/31/2008?


  #3  
Old January 11th, 2010, 02:38 AM posted to microsoft.public.excel.worksheet.functions
T. Valko
external usenet poster
 
Posts: 15,759
Default Same Date a year ago

Try it like this...

=DATE(YEAR(B2)-1,MONTH(B2),DAY(B2))

However, if the referenced date just happens to be the leap day of a leap
year you might get a result that you don't expect. For example:

B2 = 2/29/2008

What is the same date one year ago? There was no 2/29/2007. So, you have to
settle for either 2/28/2007 or 3/1/2007. The above formula will return
3/1/2007. This formula will return 2/28/2007:

=EDATE(B2,-12)

Format as Date

Note that the EDATE function requires the Analysis ToolPak add-in be
installed if you're using a version of Excel prior to Excel 2007. If you
enter the formula and get a #NAME? error look in Excel help for the EDATE
function. It'll tell you how to fix the problem.

--
Biff
Microsoft Excel MVP


"Joe" wrote in message
news
I am using

=DATE(YEAR(B2)-1,MONTH(B2)-0,1)

to return the same date for the previous year.

If B2 is 12/31/2009 it returns 12/1/2008 instead of 12/31/2008.

How do I get it to return 12/31/2008?



  #4  
Old January 11th, 2010, 02:45 AM posted to microsoft.public.excel.worksheet.functions
Ron Rosenfeld
external usenet poster
 
Posts: 3,719
Default Same Date a year ago

On Sun, 10 Jan 2010 17:59:01 -0800, Joe wrote:

I am using

=DATE(YEAR(B2)-1,MONTH(B2)-0,1)

to return the same date for the previous year.

If B2 is 12/31/2009 it returns 12/1/2008 instead of 12/31/2008.

How do I get it to return 12/31/2008?


=DATE(YEAR(B2)-1,MONTH(B2)-0,DAY(B2))

Of course, the "-0" is superfluous, and subtracting one year from 2/29/2008 --
3/1/2007. Depending on what you want, further modifications could be used.

If the "-0" is a placeholder for subtraction of months, you'll need to decide
what you want to do if the resultant month has fewer days than the initial
month.

Finally, you could also consider using the EDATE worksheet function and
subtract 12 months. For versions of Excel prior to 2007, you'll need to
install the Analysis Toolpak. See HELP for the EDATE function for both
instructions as to how to install the ATP, and also for the proper syntax for
the function.

If you cannot install the ATP, you could use this formula to mimic EDATE:

=MIN(DATE(YEAR(B2),MONTH(B2)+B3+{1,0},DAY(B2)*{0,1 }

where B3 stores the number of months that you want to add or subtract (entered
as a positive or negative number).

--ron
  #5  
Old January 11th, 2010, 03:14 PM posted to microsoft.public.excel.worksheet.functions
Ashish Mathur[_2_]
external usenet poster
 
Posts: 1,764
Default Same Date a year ago

Hi,

You may try the EDATE function. This formula will get you 12/31/2008.
Please note that in Excel 2003 and prior versions one will have to install
the Analysis Toolpak addin from Tools Addin for the EDATE to work.

=EDATE(M8,-12)

--
Regards,

Ashish Mathur
Microsoft Excel MVP
www.ashishmathur.com

"Joe" wrote in message
news
I am using

=DATE(YEAR(B2)-1,MONTH(B2)-0,1)

to return the same date for the previous year.

If B2 is 12/31/2009 it returns 12/1/2008 instead of 12/31/2008.

How do I get it to return 12/31/2008?


 




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 05:38 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.