formula for month that is prior to actual

B

braadi

i generate reports for data collected from the previous month (i.e. in
december, i report for november's data). how do i formulate in my reports
the date to show the previous month and year (while automatically updating
according to excel date and time)?
 
T

TedMi

=DATE(IF(MONTH(NOW())=1,YEAR(NOW())-1,YEAR(NOW())),
IF(MONTH(NOW())=1,12,MONTH(NOW())-1), 28)
This might be easier to follow if you store intermediate results in cells:
A1: =IF(MONTH(NOW())=1,12,MONTH(NOW())-1)
A2: =IF(A1=12,YEAR(NOW())-1, YEAR(NOW)))

=Date(A2, A1, 28)

This assumes that you put the DATE function in a cell formatted to show
mm/yyyy. In that case, the day arg to the DATE function is arbitrary and can
be any day number which appears in every month (i.e. 1-28).
 

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

Top