v.21.3Improvement

Fix DateTime64 Clamping to Match DateTime Behavior

Fix toDateTime64(toDate()/toDateTime()) for DateTime64 - Implement DateTime64 clamping to match DateTime behaviour. #20131 (Azat Khuzhin).
Fixed toDateTime64 conversion from toDate/toDateTime to correctly clamp values, matching the behavior of DateTime.

Why it matters

This fix addresses inconsistencies in the clamping behavior of DateTime64 when converting from Date or DateTime. It ensures that the result of these conversions respects the same limits as DateTime, preventing unexpected out-of-range values and improving reliability.

How to use it

Users benefit from this fix automatically when converting with toDateTime64(toDate()) or toDateTime64(toDateTime()), as the clamping behavior now aligns with DateTime. No special configuration is required.