# Queries involving dates don't seem to work?

**URL:** <https://community.auth0.com/t/queries-involving-dates-dont-seem-to-work/88970>\
**Category:** Get Help\
**Tags:** query-parameters\
**Created:** [August 18, 2022, 2:06pm UTC](https://community.auth0.com/t/queries-involving-dates-dont-seem-to-work/88970 "2022-08-18T14:06:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![robliou01](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/robliou01/32/34126_2.png) [@robliou01](https://community.auth0.com/u/robliou01)\
**Post date:** [August 18, 2022, 2:06pm UTC](https://community.auth0.com/t/queries-involving-dates-dont-seem-to-work/88970/1 "2022-08-18T14:06:42Z")

</div>

Hi! I hope all is well.

While testing of the [management API](https://auth0.com/docs/api/management/v2/#!/Users/get_users), I’m having trouble getting my date-related queries to work.

I’m getting the management token OK, and queries not involving dates work just fine (i.e. “name”, “email”, “logins\_count”, etc.).

However, I can’t get queries involving “last\_login” or "created\_at "to return anything. Running queries involving these fields returns a Response Code of 200, but the Response Body is always ‘’ (which is incorrect since they should have entries).

Here are the q parameters that I’m testing:

created\_at:{2022-08-18 TO 2021-01-01]  
last\_login:[\* TO 2021-01-01]

As well as a full sample query:

 ![image](https://global.discourse-cdn.com/auth0/original/3X/6/f/6f413b05137bddf5dc52e074c6748371f4566e8c.png)

Also, what is the correct way to specify a range of dates relative to today (for example, the past 24 hours, or the past week)? The elastic search method that was recommended (i.e. “now-1d/d”) does not seem to be recognized by the API.

Many Thanks and hope to hear back from you soon,

Rob

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [August 18, 2022, 7:18pm UTC](https://community.auth0.com/t/queries-involving-dates-dont-seem-to-work/88970/3 "2022-08-18T19:18:08Z")

</div>

Hi @robliou01 ,

I understand that you want to search by the date time field with a range. I tested with the below q parameters and got the result.

last\_login: [“2022-08-16T17:44:50.968Z” TO “2022-08-20T17:44:50.968Z”]  
last\_login: “2022-08-16T17:44:50.968Z”

Hope it works for your use case!

---

<div class="post-metadata">

**Author:** ![robliou01](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/robliou01/32/34126_2.png) [@robliou01](https://community.auth0.com/u/robliou01)\
**Post date:** [August 19, 2022, 3:05am UTC](https://community.auth0.com/t/queries-involving-dates-dont-seem-to-work/88970/4 "2022-08-19T03:05:39Z")

</div>

Excellent, thank you Lihua!

I had the dates in descending order, which was causing the problem.

Thanks again,

Rob

---

<div class="post-metadata">

**Author:** ![lihua.zhang](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/lihua.zhang/32/39683_2.png) [@lihua.zhang](https://community.auth0.com/u/lihua.zhang)\
**Post date:** [August 19, 2022, 3:29am UTC](https://community.auth0.com/t/queries-involving-dates-dont-seem-to-work/88970/5 "2022-08-19T03:29:51Z")

</div>

You are very welcome! 🤝

---

<div class="post-metadata">

**Author:** ![konrad.sopala](https://sea1.discourse-cdn.com/auth0/user_avatar/community.auth0.com/konrad.sopala/32/13516_2.png) [@konrad.sopala](https://community.auth0.com/u/konrad.sopala)\
**Post date:** [December 22, 2022, 9:39am UTC](https://community.auth0.com/t/queries-involving-dates-dont-seem-to-work/88970/6 "2022-12-22T09:39:16Z")

</div>


