2

So I have this query which goes like

query = MyModel.objects.filter(some_filter).filter(eventTime__date__gte=start_date).filter(eventTime__date__lte=end_date)....

The redshift table I am connecting to has eventTime as UTC. It offers me to query in native SQL like

select eventtime AT TIME ZONE 'MST' from mymodel limit 1;

How can I use that AT TIME ZONE 'MST' in django query format?

Sumit Sinha
  • 666
  • 3
  • 9
  • 18

1 Answers1

0

For the purposes of "at time zone" postgres and redshift are the same.

This should be of help https://github.com/counsyl/django-postgres-timezones

Django does not use the at time zone syntax when constructing queries and thus if USE_TZ is False the timestamps that Django loads are converted (by Postgres) to the settings.TIME_ZONE time zone (remember Django configures the database connection with that time zone) and stored on your models as naive Python datetimes

Jon Scott
  • 4,144
  • 17
  • 29