diff --git a/webinterface.py b/webinterface.py
index 0f6bd3ffd..c4ed6ed37 100644
--- a/webinterface.py
+++ b/webinterface.py
@@ -2825,7 +2825,7 @@ def htmlCalendar(translate: {}, \
for weekOfMonth in range(1,6):
calendarStr+='
\n'
for dayNumber in range(1,8):
- if (weekOfMonth>1 and dayOfMonth<=daysInMonth) or \
+ if (weekOfMonth>1 and dayOfMonth=dow):
dayOfMonth+=1
calendarStr+='