Skip to content
Advertisement

Django annotate add interval to date

I am using postgres database with Django 2.2. I need to combine date and time field in model and add an interval of one day in it. I have done first part like this.

Now I have to add 1 day to end_dt. I have done this with plain sql like this.

How can I achieve this using django ORM? Or is it even achievable?

Advertisement

Answer

After a bit of experimentation I have found that adding timedelta from datetime works just fine 🙂

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement