|
@@ -45,7 +45,7 @@ emp_no:integer | x:date
|
|
|
|
|
|
|
|
|
evalDateFormat
|
|
|
-from employees | sort hire_date | eval x = date_format(hire_date), y = date_format(hire_date, "YYYY-MM-dd") | keep emp_no, x, y | limit 5;
|
|
|
+from employees | sort hire_date | eval x = date_format(hire_date), y = date_format("YYYY-MM-dd", hire_date) | keep emp_no, x, y | limit 5;
|
|
|
|
|
|
emp_no:integer | x:keyword | y:keyword
|
|
|
10009 | 1985-02-18T00:00:00.000Z | 1985-02-18
|
|
@@ -295,7 +295,7 @@ hire_date:date | hd:date
|
|
|
;
|
|
|
|
|
|
now
|
|
|
-row a = now() | eval x = a == now(), y = substring(date_format(a, "yyyy"), 0, 2) | keep x, y;
|
|
|
+row a = now() | eval x = a == now(), y = substring(date_format("yyyy", a), 0, 2) | keep x, y;
|
|
|
|
|
|
x:boolean | y:keyword
|
|
|
true | 20
|
|
@@ -338,14 +338,14 @@ AVG(salary):double | bucket:date
|
|
|
;
|
|
|
|
|
|
evalDateParseWithSimpleDate
|
|
|
-row a = "2023-02-01" | eval b = date_parse(a, "yyyy-MM-dd") | keep b;
|
|
|
+row a = "2023-02-01" | eval b = date_parse("yyyy-MM-dd", a) | keep b;
|
|
|
|
|
|
b:datetime
|
|
|
2023-02-01T00:00:00.000Z
|
|
|
;
|
|
|
|
|
|
evalDateParseWithDateTime
|
|
|
-row a = "2023-02-01 12:15:55" | eval b = date_parse(a, "yyyy-MM-dd HH:mm:ss") | keep b;
|
|
|
+row a = "2023-02-01 12:15:55" | eval b = date_parse("yyyy-MM-dd HH:mm:ss", a) | keep b;
|
|
|
|
|
|
b:datetime
|
|
|
2023-02-01T12:15:55.000Z
|
|
@@ -359,8 +359,8 @@ b:datetime
|
|
|
;
|
|
|
|
|
|
evalDateParseWrongDate
|
|
|
-row a = "2023-02-01 foo" | eval b = date_parse(a, "yyyy-MM-dd") | keep b;
|
|
|
-warning:Line 1:37: evaluation of [date_parse(a, \"yyyy-MM-dd\")] failed, treating result as null. Only first 20 failures recorded.
|
|
|
+row a = "2023-02-01 foo" | eval b = date_parse("yyyy-MM-dd", a) | keep b;
|
|
|
+warning:Line 1:37: evaluation of [date_parse(\"yyyy-MM-dd\", a)] failed, treating result as null. Only first 20 failures recorded.
|
|
|
warning:java.lang.IllegalArgumentException: failed to parse date field [2023-02-01 foo] with format [yyyy-MM-dd]
|
|
|
|
|
|
b:datetime
|
|
@@ -368,16 +368,16 @@ null
|
|
|
;
|
|
|
|
|
|
evalDateParseNotMatching
|
|
|
-row a = "2023-02-01" | eval b = date_parse(a, "yyyy-MM") | keep b;
|
|
|
-warning:Line 1:33: evaluation of [date_parse(a, \"yyyy-MM\")] failed, treating result as null. Only first 20 failures recorded.
|
|
|
+row a = "2023-02-01" | eval b = date_parse("yyyy-MM", a) | keep b;
|
|
|
+warning:Line 1:33: evaluation of [date_parse(\"yyyy-MM\", a)] failed, treating result as null. Only first 20 failures recorded.
|
|
|
warning:java.lang.IllegalArgumentException: failed to parse date field [2023-02-01] with format [yyyy-MM]
|
|
|
b:datetime
|
|
|
null
|
|
|
;
|
|
|
|
|
|
evalDateParseNotMatching2
|
|
|
-row a = "2023-02-01" | eval b = date_parse(a, "yyyy-MM-dd HH:mm:ss") | keep b;
|
|
|
-warning:Line 1:33: evaluation of [date_parse(a, \"yyyy-MM-dd HH:mm:ss\")] failed, treating result as null. Only first 20 failures recorded.
|
|
|
+row a = "2023-02-01" | eval b = date_parse("yyyy-MM-dd HH:mm:ss", a) | keep b;
|
|
|
+warning:Line 1:33: evaluation of [date_parse(\"yyyy-MM-dd HH:mm:ss\", a)] failed, treating result as null. Only first 20 failures recorded.
|
|
|
warning:java.lang.IllegalArgumentException: failed to parse date field [2023-02-01] with format [yyyy-MM-dd HH:mm:ss]
|
|
|
|
|
|
b:datetime
|
|
@@ -385,7 +385,7 @@ null
|
|
|
;
|
|
|
|
|
|
evalDateParseNullPattern
|
|
|
-row a = "2023-02-01" | eval b = date_parse(a, null) | keep b;
|
|
|
+row a = "2023-02-01" | eval b = date_parse(null, a) | keep b;
|
|
|
|
|
|
b:datetime
|
|
|
null
|
|
@@ -393,8 +393,8 @@ null
|
|
|
|
|
|
evalDateParseDynamic
|
|
|
from employees | where emp_no == 10039 or emp_no == 10040 | sort emp_no
|
|
|
-| eval birth_date_string = date_format(birth_date, "yyyy-MM-dd")
|
|
|
-| eval new_date = date_parse(birth_date_string, "yyyy-MM-dd") | eval bool = new_date == birth_date | keep emp_no, new_date, birth_date, bool;
|
|
|
+| eval birth_date_string = date_format("yyyy-MM-dd", birth_date)
|
|
|
+| eval new_date = date_parse("yyyy-MM-dd", birth_date_string) | eval bool = new_date == birth_date | keep emp_no, new_date, birth_date, bool;
|
|
|
|
|
|
emp_no:integer | new_date:datetime | birth_date:datetime | bool:boolean
|
|
|
10039 | 1959-10-01 | 1959-10-01 | true
|
|
@@ -403,8 +403,8 @@ emp_no:integer | new_date:datetime | birth_date:datetime | bool:boolean
|
|
|
|
|
|
evalDateParseDynamic2
|
|
|
from employees | where emp_no >= 10047 | sort emp_no | where emp_no <= 10051
|
|
|
-| eval birth_date_string = date_format(birth_date, "yyyy-MM-dd")
|
|
|
-| eval new_date = date_parse(birth_date_string, "yyyy-MM-dd")
|
|
|
+| eval birth_date_string = date_format("yyyy-MM-dd", birth_date)
|
|
|
+| eval new_date = date_parse("yyyy-MM-dd", birth_date_string)
|
|
|
| keep emp_no, new_date, birth_date | eval bool = new_date == birth_date;
|
|
|
|
|
|
emp_no:integer | new_date:datetime | birth_date:datetime | bool:boolean
|
|
@@ -418,8 +418,8 @@ emp_no:integer | new_date:datetime | birth_date:datetime | bool:boo
|
|
|
|
|
|
evalDateParseDynamicDateAndPattern
|
|
|
from employees | where emp_no == 10049 or emp_no == 10050 | sort emp_no
|
|
|
-| eval pattern = "yyyy-MM-dd", birth_date_string = date_format(birth_date, pattern)
|
|
|
-| eval new_date = date_parse(birth_date_string, "yyyy-MM-dd") | eval bool = new_date == birth_date | keep emp_no, new_date, birth_date, bool;
|
|
|
+| eval pattern = "yyyy-MM-dd", birth_date_string = date_format(pattern, birth_date)
|
|
|
+| eval new_date = date_parse("yyyy-MM-dd", birth_date_string) | eval bool = new_date == birth_date | keep emp_no, new_date, birth_date, bool;
|
|
|
|
|
|
emp_no:integer | new_date:datetime | birth_date:datetime | bool:boolean
|
|
|
10049 | null | null | null
|
|
@@ -437,7 +437,7 @@ emp_no:integer | new_date:datetime | birth_date:datetime | bool:
|
|
|
|
|
|
dateFields
|
|
|
from employees | where emp_no == 10049 or emp_no == 10050
|
|
|
-| eval year = date_extract(birth_date, "year"), month = date_extract(birth_date, "month_of_year"), day = date_extract(birth_date, "day_of_month")
|
|
|
+| eval year = date_extract("year", birth_date), month = date_extract("month_of_year", birth_date), day = date_extract("day_of_month", birth_date)
|
|
|
| keep emp_no, year, month, day;
|
|
|
ignoreOrder:true
|
|
|
|
|
@@ -449,7 +449,7 @@ emp_no:integer | year:long | month:long | day:long
|
|
|
|
|
|
dateFormatLocale
|
|
|
from employees | where emp_no == 10049 or emp_no == 10050 | sort emp_no
|
|
|
-| eval birth_month = date_format(birth_date, "MMMM") | keep emp_no, birth_date, birth_month;
|
|
|
+| eval birth_month = date_format("MMMM", birth_date) | keep emp_no, birth_date, birth_month;
|
|
|
ignoreOrder:true
|
|
|
|
|
|
emp_no:integer | birth_date:datetime | birth_month:keyword
|