diff --git a/internal/function_time_parser.go b/internal/function_time_parser.go index 3802ef4..973a72e 100644 --- a/internal/function_time_parser.go +++ b/internal/function_time_parser.go @@ -1083,7 +1083,9 @@ func parseTimeFormat(formatStr, targetStr string, typ TimeFormatType) (*time.Tim targetIdx int formatIdx int ) - ret := &time.Time{} + epoch := time.Unix(0, 0) + var ret = &epoch + for formatIdx < len(format) { c := format[formatIdx] if c == '%' { diff --git a/query_test.go b/query_test.go index 2dc0a5a..3a176ef 100644 --- a/query_test.go +++ b/query_test.go @@ -3640,6 +3640,12 @@ WITH example AS ( {now.Format("2006-01-02")}, }, }, + { + name: "base date is epoch", + query: `SELECT PARSE_DATE("%m", "03")`, + expectedRows: [][]interface{}{ + {"1970-03-01"}, + }}, { name: "extract date", query: `