# User session query between 9am to 7pm in a week

**URL:** <https://community.dynatrace.com/t/user-session-query-between-9am-to-7pm-in-a-week/43930>\
**Category:** Real User Monitoring\
**Tags:** user-sessions\
**Created:** [February 1, 2024, 12:40pm UTC](https://community.dynatrace.com/t/user-session-query-between-9am-to-7pm-in-a-week/43930 "2024-02-01T12:40:40Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![cleoleeps](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@cleoleeps](https://community.dynatrace.com/u/cleoleeps)\
**Post date:** [February 1, 2024, 12:40pm UTC](https://community.dynatrace.com/t/user-session-query-between-9am-to-7pm-in-a-week/43930/1 "2024-02-01T12:40:40Z")

</div>

Normally we pull user session query data by using the timeframe on top right of the page (e.g. 1 Jan 2024 - 20 Jan 2024)

But recently we are requested to show the data between 9am - 7pm for a week.

I was trying to do it via user session query but the moment I added the **HOUR(starttime) \>= ‘10’** or so,&nbsp; it just gave error: “Query parsing error”

Is the request doable actually?

Is this query something wrong?

SELECT starttime,

DATETIME(starttime), MONTH(starttime), DAY(starttime), HOUR(starttime)

FROM useraction where usersession.country IN (“United Kingdom”) And HOUR(starttime)\>=‘10’ and HOUR(starttime) \<=‘19’

ORDER BY starttime, HOUR(starttime) ASC

---

<div class="post-metadata">

**Author:** ![dannemca](https://dub1.discourse-cdn.com/dynatrace/user_avatar/community.dynatrace.com/dannemca/32/7215_2.png) [@dannemca](https://community.dynatrace.com/u/dannemca)\
**Post date:** [February 1, 2024, 8:39pm UTC](https://community.dynatrace.com/t/user-session-query-between-9am-to-7pm-in-a-week/43930/2 "2024-02-01T20:39:11Z")

</div>

The problem is with your Where condition.

Thats the only format it does support:

> **[Custom queries, segmentation, and aggregation of session data in RUM Classic](https://docs.dynatrace.com/docs/observe/digital-experience/rum-classic/session-segmentation/custom-queries-segmentation-and-aggregation-of-session-data)**
>
> Learn how you can access and query user session data based on keywords, syntax, functions, and more.

Format Description Example

| — | Unix timestamp as a number in milliseconds | 1514152800000 |
| --- | --- | --- |
| yyyy-MM-dd’T’HH:mm:ssZ | ISO datetime with the time zone | 2017-12-24T21:00:00+01:00 |
| yyyy-MM-dd HH:mm:ss | Date with optional time | 2017-12-24 21:00 |
| yyyy/MM/dd HH:mm:ss | Date with optional time | 2017/12/24 21 |
| MM/dd/yyyy HH:mm:ss | Date with optional time | 12/24/2017 |
| dd.MM.yyyy HH:mm:ss | Date with optional time | 24.12.2017 21:00:00 |

---

<div class="post-metadata">

**Author:** ![cleoleeps](https://avatars.discourse-cdn.com/v4/letter/c/bc8723/32.png) [@cleoleeps](https://community.dynatrace.com/u/cleoleeps)\
**Post date:** [February 2, 2024, 12:29pm UTC](https://community.dynatrace.com/t/user-session-query-between-9am-to-7pm-in-a-week/43930/3 "2024-02-02T12:29:41Z")

</div>

Yeah i read that too about timestamp. But I just wanted to filter by the hour not the date. Hence it’s a bit tricky here.

The USQL able to get data for HOUR(starttime) as seen in the result table below. But unfortunately I can’t use it to do further filtering.

 ![cleoleeps_0-1706876605904.png](https://global.discourse-cdn.com/dynatrace/original/3X/b/2/b2389d3e5208d09a5370eac50f0fe33891c11f15.png)

---

<div class="post-metadata">

**Author:** ![Gosia\_Murawska](https://avatars.discourse-cdn.com/v4/letter/g/2bfe46/32.png) [@Gosia\_Murawska](https://community.dynatrace.com/u/Gosia_Murawska)\
**Post date:** [August 13, 2024, 2:06pm UTC](https://community.dynatrace.com/t/user-session-query-between-9am-to-7pm-in-a-week/43930/4 "2024-08-13T14:06:52Z")

</div>

Hi&nbsp;[@cleoleeps](https://community.dynatrace.com/user/45561)&nbsp;  
Have you managed to solve the problem? It would be great if you shared the solution with the Community users 🙂
