diff --git a/src/backend/utils/adt/datetime.c b/src/backend/utils/adt/datetime.c
index 2a44b6e..fe0ba80 100644
--- a/src/backend/utils/adt/datetime.c
+++ b/src/backend/utils/adt/datetime.c
@@ -371,8 +371,11 @@ GetCurrentDateTime(struct pg_tm * tm)
 	int			tz;
 	fsec_t		fsec;
 
-	timestamp2tm(GetCurrentTransactionStartTimestamp(), &tz, tm, &fsec,
-				 NULL, NULL);
+	if (timestamp2tm(GetCurrentTransactionStartTimestamp(), &tz, tm, &fsec,
+					 NULL, NULL) != 0)
+		ereport(ERROR,
+				(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
+				 errmsg("timestamp out of range")));
 	/* Note: don't pass NULL tzp to timestamp2tm; affects behavior */
 }
 
@@ -387,8 +390,11 @@ GetCurrentTimeUsec(struct pg_tm * tm, fsec_t *fsec, int *tzp)
 {
 	int			tz;
 
-	timestamp2tm(GetCurrentTransactionStartTimestamp(), &tz, tm, fsec,
-				 NULL, NULL);
+	if (timestamp2tm(GetCurrentTransactionStartTimestamp(), &tz, tm, fsec,
+					 NULL, NULL) != 0)
+		ereport(ERROR,
+				(errcode(ERRCODE_DATETIME_VALUE_OUT_OF_RANGE),
+				 errmsg("timestamp out of range")));
 	/* Note: don't pass NULL tzp to timestamp2tm; affects behavior */
 	if (tzp != NULL)
 		*tzp = tz;
