diff --git a/SAS/TMSS/backend/services/scheduling/lib/constraints/template_constraints_v1.py b/SAS/TMSS/backend/services/scheduling/lib/constraints/template_constraints_v1.py
index 271ba25a5a23c43672976e87a6c540195595ce9a..3ad3413b3aa9a0696680f2e1e8a23d9e453c7bbb 100644
--- a/SAS/TMSS/backend/services/scheduling/lib/constraints/template_constraints_v1.py
+++ b/SAS/TMSS/backend/services/scheduling/lib/constraints/template_constraints_v1.py
@@ -166,17 +166,17 @@ def can_run_within_timewindow_with_time_constraints(scheduling_unit: models.Sche
         if (at >= lower_bound and at + scheduling_unit.duration <= upper_bound):    # todo: suggestion: use scheduling_unit.requirements_doc['tasks']['Observation']['specifications_doc']['duration']
             return can_run_anywhere_within_timewindow_with_time_constraints(scheduling_unit, lower_bound=at,
                                                                             upper_bound=at + scheduling_unit.duration)
+    else:
+        duration = timedelta(
+            seconds=scheduling_unit.requirements_doc['tasks'][main_observation_task_name]['specifications_doc']['duration'])
+        window_lower_bound = lower_bound
+        while window_lower_bound + duration <= upper_bound:
+            window_upper_bound = window_lower_bound + duration
+            if can_run_anywhere_within_timewindow_with_time_constraints(scheduling_unit, window_lower_bound, window_upper_bound):
+                return True
+            window_lower_bound += min(timedelta(hours=1), upper_bound - window_lower_bound)
 
-    duration = timedelta(
-        seconds=scheduling_unit.requirements_doc['tasks'][main_observation_task_name]['specifications_doc']['duration'])
-    window_lower_bound = lower_bound
-    while window_lower_bound + duration <= upper_bound:
-        window_upper_bound = window_lower_bound + duration
-        if can_run_anywhere_within_timewindow_with_time_constraints(scheduling_unit, window_lower_bound, window_upper_bound):
-            return True
-        window_lower_bound += min(timedelta(hours=1), upper_bound - window_lower_bound)
-
-    return False
+        return False
 
 
 def can_run_anywhere_within_timewindow_with_time_constraints(scheduling_unit: models.SchedulingUnitBlueprint, lower_bound: datetime, upper_bound: datetime) -> bool:
diff --git a/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py b/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py
index eea170dc26987c54a43702af4168c15872f9538c..7b970c4a52f08b815c70b875fa3b1c6b2d56cb75 100755
--- a/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py
+++ b/SAS/TMSS/backend/services/scheduling/test/t_dynamic_scheduling.py
@@ -1109,8 +1109,26 @@ class TestTimeConstraints(TestCase):
         self.clear_time_constraints()
         self.assertTrue(self.execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary())
 
-        self.add_time_at_constraint(datetime(2020, 1, 1, 13, 0, 0))
-        self.assertTrue(self.execute_can_run_within_timewindow_with_time_constraints_of_24hour_boundary())
+        # Set datetime constraint before lower_bound
+        self.clear_time_constraints()
+        self.add_time_at_constraint(datetime(2020, 1, 1, 11, 0, 0))
+        self.assertFalse(tc1.can_run_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint,
+                                                                            datetime(2020, 1, 1, 12, 0, 0),
+                                                                            datetime(2020, 1, 1, 14, 0, 0)))
+
+        # Set datetime constraint at lower_bound, but duration exceeds upper_bound
+        self.clear_time_constraints()
+        self.add_time_at_constraint(datetime(2020, 1, 1, 12, 0, 0))
+        self.assertFalse(tc1.can_run_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint,
+                                                                            datetime(2020, 1, 1, 12, 0, 0),
+                                                                            datetime(2020, 1, 1, 14, 0, 0)))
+
+        # Set datetime constraint after upper_bound
+        self.clear_time_constraints()
+        self.add_time_at_constraint(datetime(2020, 1, 2, 15, 0, 0))
+        self.assertFalse(tc1.can_run_within_timewindow_with_time_constraints(self.scheduling_unit_blueprint,
+                                                                            datetime(2020, 1, 1, 12, 0, 0),
+                                                                            datetime(2020, 1, 1, 14, 0, 0)))
 
     def test_can_run_within_between_constraints(self):
         """