Hi, According to the ODBC spec ( https://docs.microsoft.com/en-us/sql/odbc/reference/appendixes/time-date-and-interval-functions?view=sql-server-2017), when the return type inference for timestampadd should be: 1. If the datetime type is a date, and the time unit is a time, promote to timestamp. (the time should be set to zero before the addition). 2. If the datetime type is a time, and the time unit is a date, promote to timestamp. (the date should be set to the current date before the addition) 3. Otherwise the return type is the same as the input type.
It looks like we handle (1) and (3) correctly, but don't do the promotion for (2). We also use the same rules for Datetime_plus. This definitely looks like a bug for timestampadd. However I don't believe this behavior is spec'd out for datetime_plus. Would it make sense to differ here? This affects the timestampadd/datetime_plus normalization (would need to inject casts when doing conversions to control return types).
