我想将日期编号转换为日期名称
i want to convert day number to day name
我想在我为其创建动态日期的一列中获取日期和日期名称,但我无法从日期编号创建日期名称并将日期和日期名称混合在一列中。请帮忙
T
| where name has "Samplelog"
| extend Eventdate = strcat(datetime_part("day",timestamp))
| extend day_strg = tostring(Eventdate)
| extend day_Alp = dynamic({"0":"Sun", "1":"Mon", "2":"Tue", "3": "Wed", "4": "Thu", "5":"Fri", "6": "Sat"})
| extend day_num = dayofweek(timestamp) / 1d
| extend months = dynamic({"1":"Jan", "2":"Feb", "3":"Mar", "4":"Apr","5":"May","6":"Jun","7":"Jul","8":"Aug","9":"Sep","10":"Oct","11":"Nov","12":"Dec"})
| extend Eventdate = strcat(datetime_part("day",timestamp),"-",months[tostring(getmonth(timestamp))], "-", getyear(timestamp))
| extend Week_Num = case(day_strg in (range(1, 7, 1)), "1", day_strg in (range(8, 14, 1)), "2",day_strg in (range(15, 21, 1)), "3",day_strg in (range(22, 31, 1)), "4", "0")
| extend weekend = iff(Week_Num in (2,4) and day_num == 6 or day_num == 0, "weekend", "working day")
//| summarize Count=count() by bin(timestamp,1d)
let prm_day_of_week = dynamic(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]);
let prm_month = dynamic(["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]);
let mydata = materialize (range i from 1 to 10 step 1 | extend dttm = ago(rand()*1d*365));
mydata
| extend dayofweek = dayofweek(dttm), monthofyear = monthofyear(dttm)
| extend dayofweek_name = prm_day_of_week[toint(dayofweek/1d)], monthofyear_name = prm_month[monthofyear-1]
i
dttm
dayofweek
monthofyear
dayofweek_name
monthofyear_name
3
2021-04-11T17:03:13.0661553Z
00:00:00
4
Sun
Apr
6
2021-05-31T20:39:37.7726143Z
1.00:00:00
5
Mon
May
1
2021-06-21T19:11:27.7126358Z
1.00:00:00
6
Mon
Jun
10
2021-06-23T00:28:09.1442068Z
3.00:00:00
6
Wed
Jun
7
2021-06-25T22:32:22.4456643Z
5.00:00:00
6
Fri
Jun
4
2021-08-05T02:47:06.9960523Z
4.00:00:00
8
Thu
Aug
5
2021-09-24T10:09:35.0279053Z
5.00:00:00
9
Fri
Sep
8
2022-02-06T08:55:36.8755718Z
00:00:00
2
Sun
Feb
2
2022-02-28T07:11:29.5729928Z
1.00:00:00
2
Mon
Feb
9
2022-03-02T00:26:16.2603593Z
3.00:00:00
3
Wed
Mar
我想在我为其创建动态日期的一列中获取日期和日期名称,但我无法从日期编号创建日期名称并将日期和日期名称混合在一列中。请帮忙
T
| where name has "Samplelog"
| extend Eventdate = strcat(datetime_part("day",timestamp))
| extend day_strg = tostring(Eventdate)
| extend day_Alp = dynamic({"0":"Sun", "1":"Mon", "2":"Tue", "3": "Wed", "4": "Thu", "5":"Fri", "6": "Sat"})
| extend day_num = dayofweek(timestamp) / 1d
| extend months = dynamic({"1":"Jan", "2":"Feb", "3":"Mar", "4":"Apr","5":"May","6":"Jun","7":"Jul","8":"Aug","9":"Sep","10":"Oct","11":"Nov","12":"Dec"})
| extend Eventdate = strcat(datetime_part("day",timestamp),"-",months[tostring(getmonth(timestamp))], "-", getyear(timestamp))
| extend Week_Num = case(day_strg in (range(1, 7, 1)), "1", day_strg in (range(8, 14, 1)), "2",day_strg in (range(15, 21, 1)), "3",day_strg in (range(22, 31, 1)), "4", "0")
| extend weekend = iff(Week_Num in (2,4) and day_num == 6 or day_num == 0, "weekend", "working day")
//| summarize Count=count() by bin(timestamp,1d)
let prm_day_of_week = dynamic(["Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat"]);
let prm_month = dynamic(["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"]);
let mydata = materialize (range i from 1 to 10 step 1 | extend dttm = ago(rand()*1d*365));
mydata
| extend dayofweek = dayofweek(dttm), monthofyear = monthofyear(dttm)
| extend dayofweek_name = prm_day_of_week[toint(dayofweek/1d)], monthofyear_name = prm_month[monthofyear-1]
i | dttm | dayofweek | monthofyear | dayofweek_name | monthofyear_name |
---|---|---|---|---|---|
3 | 2021-04-11T17:03:13.0661553Z | 00:00:00 | 4 | Sun | Apr |
6 | 2021-05-31T20:39:37.7726143Z | 1.00:00:00 | 5 | Mon | May |
1 | 2021-06-21T19:11:27.7126358Z | 1.00:00:00 | 6 | Mon | Jun |
10 | 2021-06-23T00:28:09.1442068Z | 3.00:00:00 | 6 | Wed | Jun |
7 | 2021-06-25T22:32:22.4456643Z | 5.00:00:00 | 6 | Fri | Jun |
4 | 2021-08-05T02:47:06.9960523Z | 4.00:00:00 | 8 | Thu | Aug |
5 | 2021-09-24T10:09:35.0279053Z | 5.00:00:00 | 9 | Fri | Sep |
8 | 2022-02-06T08:55:36.8755718Z | 00:00:00 | 2 | Sun | Feb |
2 | 2022-02-28T07:11:29.5729928Z | 1.00:00:00 | 2 | Mon | Feb |
9 | 2022-03-02T00:26:16.2603593Z | 3.00:00:00 | 3 | Wed | Mar |