In date intervals, MySQL is 1 MONTH the same as 30 Days? Is 1 QUARTER the same as 3 MONTHS? And so on?

I am trying to write a PHP script that will process recurring payments every month, quarter, year, etc. This script will work as a Cron night task.

I don’t want to face a situation when someone signs up, say, on January 15th, and then again receives the bill on February 1st.

Is this what will happen if I make my last payment against INTERVAL 1 MONTH? Or will it be the same as INTERVAL 30 DAY and only process the payment again on February 15th, what do I want?

+4
source share
1 answer

MYSQL Validation

If you add MONTH, YEAR_MONTH or YEAR, and the total date has a day that is more than the maximum day for the new month, the day adjusted for the maximum days in the new month:

mysql> SELECT DATE_ADD ('2009-01-30', INTERVAL 1 MONTH); -> '2009-02-28 "Arithmetic date operations require complete dates and do not work with incomplete dates, such as" 2006-07-00 "or poorly formatted dates:

Thus, if you use 1 month of the built-in function, you do not need to worry when the last day of the month. MYSQL does all the work for you.

+4
source

All Articles