diff --git a/src/mtime_timedelta.c b/src/mtime_timedelta.c
index e709d55629c05f42a4b9151fda59f0c728104127..98d24363171475db0a9293b5e40e941b06a88d01 100644
--- a/src/mtime_timedelta.c
+++ b/src/mtime_timedelta.c
@@ -1213,7 +1213,7 @@ divideTimeDelta(struct _timedelta* dividend, struct _timedelta* divisor,
   quo_ret->quotient        = (int64_t) 0;
   quo_ret->remainder_days  = (int64_t) 0;
   quo_ret->remainder_in_ms = (int64_t) 0;
-  if (ret != 0) {
+  if (ret == 0) {
     quo_ret->quotient        = (int64_t) q_decimal;
     quo_ret->remainder_days  = (int64_t) remainder_days;
     quo_ret->remainder_in_ms = (int64_t) remainder_ms;
@@ -1231,7 +1231,7 @@ divideTimeDelta(struct _timedelta* dividend, struct _timedelta* divisor,
   deallocateJulianDelta(jd_dividend);
   deallocateJulianDelta(jd_divisor);
 
-  if (ret == 0)  return NULL;
+  if (ret != 0)  return NULL;
 
   return (quo_ret);
 }