diff --git a/src/Functions/FunctionsConversion.h b/src/Functions/FunctionsConversion.h index 9c4085f9745..2e21932d0e2 100644 --- a/src/Functions/FunctionsConversion.h +++ b/src/Functions/FunctionsConversion.h @@ -145,13 +145,6 @@ struct ConvertImpl using ColVecFrom = typename FromDataType::ColumnType; using ColVecTo = typename ToDataType::ColumnType; - if (std::is_same_v) - { - if (isDateOrDate32(named_from.type)) - throw Exception(ErrorCodes::ILLEGAL_COLUMN, "Illegal type {} of first argument of function {}", - named_from.type->getName(), Name::name); - } - if constexpr ((IsDataTypeDecimal || IsDataTypeDecimal) && !(std::is_same_v || std::is_same_v)) { @@ -306,6 +299,8 @@ struct ConvertImpl { if constexpr (std::is_same_v && std::is_same_v) vec_to[i] = static_cast(static_cast(vec_from[i])); + else if constexpr (std::is_same_v && (std::is_same_v || std::is_same_v)) + vec_to[i] = static_cast(vec_from[i] * 86400); else vec_to[i] = static_cast(vec_from[i]); } diff --git a/tests/queries/0_stateless/01592_toUnixTimestamp_Date.reference b/tests/queries/0_stateless/01592_toUnixTimestamp_Date.reference index e69de29bb2d..f7d86529347 100644 --- a/tests/queries/0_stateless/01592_toUnixTimestamp_Date.reference +++ b/tests/queries/0_stateless/01592_toUnixTimestamp_Date.reference @@ -0,0 +1,4 @@ +1683676800 +1683676800 +1683676800 +1683676800 diff --git a/tests/queries/0_stateless/01592_toUnixTimestamp_Date.sql b/tests/queries/0_stateless/01592_toUnixTimestamp_Date.sql index e8411484d71..f2ba18a3b55 100644 --- a/tests/queries/0_stateless/01592_toUnixTimestamp_Date.sql +++ b/tests/queries/0_stateless/01592_toUnixTimestamp_Date.sql @@ -1 +1,4 @@ -select toUnixTimestamp(today()); -- { serverError 44 } +select toUnixTimestamp(makeDate(2023, 5, 10)); +select toUnixTimestamp(makeDate32(2023, 5, 10)); +select toUnixTimestamp(makeDate(2023, 5, 10), 'Pacific/Auckland'); +select toUnixTimestamp(makeDate32(2023, 5, 10), 'Pacific/Auckland'); \ No newline at end of file