# Nested IF with Day and Month

Hello

I have a LibreOffice Calc spreadsheet where I keep a daily record of Distance and Time where:- Column A = Date Column B = Distance (Miles) Column C = Time (Minutes) I then have additional columns including monthly and yearly totals.

In Column D (Monthly Miles) I have the formula =IF(DAY(A32)=1,0,D31)+B32 which reads:- If the Day in Column A is 1 (the first of the month) then reset the monthly total to 0 (zero) otherwise read the previous day for this month (D31) and in either case add today's mileage (B32).

The above works fine resetting the monthly total to zero on the first day of each month but I can't work out how to create a similar formula in Column E to reset the year column to zero on 1st January each year. Something along the lines IF(Day)=1 & (Month)=1, then Zero, otherwise copy previous day and add today seems likely but I just can't work out the syntax. If there is a better solution that would be welcome.

Mike

edit retag close merge delete

=IF(AND(Day=1,Month=1),"True", "False") - is that what you are looking for that both conditions need to be met ? This is just meta syntax, obviously Day must be something like DAY(Axx), same for Month). Your existing IF for the first day of a month may got to the "False" argument.

( 2019-07-04 17:50:03 +0200 )edit

Sort by » oldest newest most voted

For the records:

=IF(AND(Day=1,Month=1),"True", "False") - is the formula for both conditions to be met. This is just meta syntax, obviously Day must be something like DAY(Axx), same for Month). Your existing IF for the first day of a month may got to the "False" argument.

more

Thank you so much for your quick reply. That is exactly what I wanted and it works fine.

more

Pleae do not post an answer, if you actually don't answer a question

( 2019-07-04 18:07:53 +0200 )edit