# How to use "AT TIME ZONE" in queryset.

**URL:** <https://forum.djangoproject.com/t/how-to-use-at-time-zone-in-queryset/25733>\
**Category:** Using the ORM\
**Created:** [November 29, 2023, 7:12am UTC](https://forum.djangoproject.com/t/how-to-use-at-time-zone-in-queryset/25733 "2023-11-29T07:12:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![lfishitkanwar](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/lfishitkanwar/32/17421_2.png) [@lfishitkanwar](https://forum.djangoproject.com/u/lfishitkanwar)\
**Post date:** [November 29, 2023, 7:12am UTC](https://forum.djangoproject.com/t/how-to-use-at-time-zone-in-queryset/25733/1 "2023-11-29T07:12:47Z")

</div>

I am using the following queryset filter →

```auto
queryset.filter(created_at __date__ gte=start_date, created_at __date__ lte=end_date)

```

and it generates the SQL as →

```auto
("tce"."created_at")::date >= 2023-11-29 AND ("tce"."created_at")::date <= 2023-11-20

```

What I need is to incorporate timezone into it such that the SQL generated would be like →

```auto
("tce"."created_at" AT TIME ZONE 'Canada/Eastern')::date >= '2023-11-28' AND ("tce"."created_at" AT TIME ZONE 'Canada/Eastern')::date <= '2023-11-28'

```

Can someone assist me on how can this be achieved using the inbuilt ORM?

---

<div class="post-metadata">

**Author:** ![lfishitkanwar](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/lfishitkanwar/32/17421_2.png) [@lfishitkanwar](https://forum.djangoproject.com/u/lfishitkanwar)\
**Post date:** [December 1, 2023, 12:09pm UTC](https://forum.djangoproject.com/t/how-to-use-at-time-zone-in-queryset/25733/2 "2023-12-01T12:09:53Z")

</div>

Can someone please help with this?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [December 1, 2023, 1:02pm UTC](https://forum.djangoproject.com/t/how-to-use-at-time-zone-in-queryset/25733/3 "2023-12-01T13:02:04Z")

</div>

There are many possibilities here, and there’s not enough information to determine which case it is.

If the `start_date` and `end_date` being submitted are user entries from a form, or are from some other type of “date-only” field, then what I think you _really_ want to do is convert those submitted dates to datetime objects for the appropriate timezone, and use _those_ converted values in the comparison. (This is what we do.) This is going to be a much faster operation on the database than requiring it to cast two fields in every row to perform the comparison.
