P
P
prrrrrrr2019-10-02 15:35:19
SQL
prrrrrrr, 2019-10-02 15:35:19

How to set monthly interval?

Tell me how to display data for the last month ( not for the last 30 days , but for the month: from the 1st to the last day of the previous month)? That is, to now count all the records that were added in September. The numbers added to the table are recorded.
I tried this, but this is just an example of what does not fit.
add_date > now() - interval 30 day

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AUser0, 2019-10-02
@prrrrrrr

If you are asking a question about SQL, you should specify the SQL tag, not PHP...
add_date > last_day(now() - interval 1 month)

L
Lander, 2019-10-02
@usdglander

Use relative formats first day of previous month and last day of previous month.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question