Home > Blockchain >  KQL - WorkDays Restrict
KQL - WorkDays Restrict

Time:11-02

i have a Question about an KQL Query. I would like to restrict the Query only of the Work Days from Monday to Friday.

How can i build this in KQL Query?

Thanks a lot.

A short Edit:

How can i build this in a existing Query with a Timestamp "timestamp between (datetime(06:00) .. datetime(15:00))" ??

For Example here the Code:

availabilityResults
| where timestamp between (datetime(06:00) .. datetime(15:00))
| where true
| where name == "warmup" and true
| extend percentage = toint(success) * 100
| render timechart

And now i would like only have an Result when is an Work Day

Best Regards, Phil

CodePudding user response:

dayofweek()

// Sample data generation. Not part of the solution.
let t = range Date from startofday(ago(28d)) to now() step 1d;
// Solution starts here.
t
| where dayofweek(Date)/1d between (1 .. 5)
Date
2022-10-05T00:00:00Z
2022-10-06T00:00:00Z
2022-10-07T00:00:00Z
2022-10-10T00:00:00Z
2022-10-11T00:00:00Z
2022-10-12T00:00:00Z
2022-10-13T00:00:00Z
2022-10-14T00:00:00Z
2022-10-17T00:00:00Z
2022-10-18T00:00:00Z
2022-10-19T00:00:00Z
2022-10-20T00:00:00Z
2022-10-21T00:00:00Z
2022-10-24T00:00:00Z
2022-10-25T00:00:00Z
2022-10-26T00:00:00Z
2022-10-27T00:00:00Z
2022-10-28T00:00:00Z
2022-10-31T00:00:00Z
2022-11-01T00:00:00Z
2022-11-02T00:00:00Z

Fiddle

CodePudding user response:

Here The Solution of my Specific Answer:

Table
| where timestamp between (datetime(06:00) .. datetime(15:00))
| where dayofweek(timestamp) != time(6.00:00:00)
| where dayofweek(timestamp) != time(0.00:00:00)
| render timechart
  • Related