Skip to content
Advertisement

SQL Between Dates as an Object [closed]

I’m trying to get only the dates between 2018 and 2020 but still get 2017… not sure if I’m missing something obvious but would love some help.

enter image description here

Advertisement

Answer

Use correct date formats:

where joined_at >= '2018-01-01' and
      joined_at < '2021-01-01'

This assumes that joined_at is stored as a date/time value. Most databases support date constants in the YYYYMMDD format.

If joined_at is stored as a string, you should fix your data model. How you do this exactly depends on the database.

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