24 Aug 2023 07:17 AM
Hello Dynatrace Community,
I've been working on some DQL queries recently and I'm trying to figure out if it's possible to split the results by calendar intervals such as a day, week, or month. I've noticed the bin and interval parameter allows for relative intervals, but I'm looking for an absolute interval based on the calendar.
Has anyone encountered this before or knows how to achieve this?
Thank you in advance!
Solved! Go to Solution.
24 Aug 2023 07:33 AM
Hi @jegron,
yes this is possible.
Can you use the new functions getDayOfWeek, getWeekOfYear, etc., to convert a timestamp field. See following example query:
fetch events
| fieldsAdd dayOfWeek = getDayOfWeek(timestamp)
| summarize count(), by:{dayOfWeek}
formatTimestamp is a more generic alternative. You can format a timestamp to your needs based on a pattern (see the link in the doc for different patterns):
fetch events
| fieldsAdd dayOfWeek = formatTimestamp(timestamp, format: "E")
| summarize count(), by:{dayOfWeek}