diff --git a/src/mtime_t_datetime.inc b/src/mtime_t_datetime.inc
index 68e13253a5e29408cf674f073b70194852ba95c7..edd7d08b0b499ce98c3e939f382def7123ec9c9d 100644
--- a/src/mtime_t_datetime.inc
+++ b/src/mtime_t_datetime.inc
@@ -153,7 +153,8 @@
     CLASS (t_datetime),  INTENT(in), target :: this
     CLASS (t_datetime),  INTENT(in), target :: dt
     type(c_ptr) :: dummy_ptr
-    dummy_ptr = my_gettimedeltafromdate(c_loc(this%dt),c_loc(dt%dt),c_loc(dt_dt_diff%td))
+    dummy_ptr = my_gettimedeltafromdatetime(c_loc(this%dt),c_loc(dt%dt),c_loc(dt_dt_diff%td))
+    CALL handle_errno(.not. c_associated(dummy_ptr), 0 * 100 + 2, __FILE__, __LINE__)
   END FUNCTION t_datetime_sub_datetime
 
   ! Overloaded operator: test for equivalence.