Skip to content
Advertisement

Get last month date range

the above query will return the last/previous month, however its missing 2 records from the last day of the last month (2022-04-30) due to the date including a time range:

I’m currently manually pulling the dates

but I want to automate this process, any help will be much obliged

Advertisement

Answer

The clearest and least error prone way to do this is as follows:

  • Use greater then equals >= for the lower limit
  • Use less than < for the upper limit, and make that limit the first of the next month
  • Don’t use between because its not intuitive what it covers and you can end up with this issue
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement