diff --git a/be/src/runtime/datetime_value.cpp b/be/src/runtime/datetime_value.cpp index b440e205c6eaba..49b84b32c782d8 100644 --- a/be/src/runtime/datetime_value.cpp +++ b/be/src/runtime/datetime_value.cpp @@ -1440,7 +1440,7 @@ bool DateTimeValue::from_date_format_str(const char* format, int format_len, con (!strict_week_number && strict_week_number_year >= 0)) { return false; } - uint64_t days = calc_daynr(strict_week_number ? strict_week_number_year : _year, 1, 1); + uint64_t days = calc_daynr(strict_week_number ? strict_week_number_year : year, 1, 1); uint8_t weekday_b = calc_weekday(days, sunday_first); diff --git a/be/test/runtime/datetime_value_test.cpp b/be/test/runtime/datetime_value_test.cpp index edf22fa1097a1b..da0053ab189e02 100644 --- a/be/test/runtime/datetime_value_test.cpp +++ b/be/test/runtime/datetime_value_test.cpp @@ -530,6 +530,14 @@ TEST_F(DateTimeValueTest, from_date_format_str) { value.to_string(str); ASSERT_STREQ("2015-01-05 12:34:56", str); + // %T + format_str = "%W %U %Y"; + value_str = "Tuesday 00 2002"; + ASSERT_TRUE(value.from_date_format_str(format_str.c_str(), format_str.size(), value_str.c_str(), + value_str.size())); + value.to_string(str); + ASSERT_STREQ("2002-01-01", str); + // hour format_str = "%Y-%m-%d %H %i %s"; value_str = "88-2-1 03 4 5";