I was off work from the 10th to the 15th with an infection.
I had to take some time off work from the 21st to the 23rd because of an infection.
この場合、次のような言い方ができます。
ーI was off work from the 10th to the 15th with an infection.
「10日から15日まで感染症で欠勤しました」
to be off work で「欠勤する」と言えます。
ーI had to take some time off work from the 21st to the 23rd because of an infection.
「21日から23日まで感染症のため欠勤しなければいけませんでした」
to take some time off work で「欠勤する・仕事を休む」と言えます。
ご参考まで!