Ask Your Question
0

Nested IF with Day and Month

asked 2019-07-04 17:08:19 +0200

emjayh gravatar image

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 flag offensive close merge delete

Comments

=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.

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

2 Answers

Sort by » oldest newest most voted
0

answered 2019-07-04 18:08:35 +0200

Opaque gravatar image

updated 2019-07-04 18:10:35 +0200

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.

If the answer is correct or helped you to fix your problem, please click the check mark (✔) next to the answer.

edit flag offensive delete link more
0

answered 2019-07-04 18:06:44 +0200

emjayh gravatar image

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

edit flag offensive delete link more

Comments

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

Opaque gravatar imageOpaque ( 2019-07-04 18:07:53 +0200 )edit
Login/Signup to Answer

Question Tools

1 follower

Stats

Asked: 2019-07-04 17:08:19 +0200

Seen: 17 times

Last updated: Jul 04