dates, 1 month prior

  • Thread starter Thread starter wfactor
  • Start date Start date
W

wfactor

Hi all,

examples of what I need, can someone assist?

Date provided = 21/05/06
I need excel to provide the date: 22/04/06

Date provided = 31/07/06
I need excel to provide the date: 01/07/06

Date provided = 01/06/06
I need excel to provide the date: 02/05/06


Thanks
 
Presuming that, for consistency with the other 2 examples,
the date needed in your lines:
Date provided = 31/07/06
I need excel to provide the date: 01/07/06

is 02/07/06

then this would suffice ..

Assuming source dates are in A1 down
In B1: =DATE(YEAR(A1),MONTH(A1)-1,DAY(A1)+1)
Copy B1 down

---
 
it doesn't fully work..

march 28 - 31
if the provided date is the 31st, and the month prior doesn't have 31
days then it also causes the wrong new date to show

provided date your formula date
4/01/2007 5/12/2006 (correct)
1/01/2007 2/12/2006 (correct)
31/03/2007 4/03/2007 (should be 01/03/07)
31/12/2006 2/12/2006 (should be 01/12/06)
 
it doesn't fully work..

Yes, but that was the stated presumption / caveat in the earlier response ..

Try instead in B1, copied down:
=IF(DATE(YEAR(A1),MONTH(A1),DAY(A1)+1)=DATE(YEAR(A1),MONTH(A1)+1,1),DATE(YEAR(A1),MONTH(A1),1),DATE(YEAR(A1),MONTH(A1)-1,DAY(A1)+1))
 
=IF(DAY(A1)>DAY(DATE(YEAR(A1),MONTH(A1),0)),DATE(YEAR(A1),MONTH(A1),1),DATE(YEAR(A1),MONTH(A1)-1,DAY(A1)+1))

HTH
 
Ardus Petus said:
=IF(DAY(A1)>DAY(DATE(YEAR(A1),MONTH(A1),0)),DATE(YEAR(A1),MONTH(A1),1),DATE(YEAR(A1),MONTH(A1)-1,DAY(A1)+1))

Think the above seems to fail with, say: 30 Apr 2006 (last day of the month,
irrespective). The formula returns: 31 Mar 2006 (instead of 1 Apr 2006) in my
tests here. Same error results as well if it's 28 Feb 2006 (returns 29 Jan
2006, instead of 1 Feb 2006). I'm of course extending the interp on the OP to
assume that OP wants it to behave like that for the last day of the month,
irrespective of how many days the month may have.

---
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top