Alpinestar22
Alpinestar22

Reputation: 543

PHP / MYSQL Date Calculations for automated billing

I am sending 'reminder' messages every 30 days, and was wondering how to calculate the time based on the timestamp I placed on the originating users signup date.

I will have a cron job run every day to query and send the messages, but I am unsure how to query the date so it will select the appropriate accounts each day and send the messages.

Any sure fire ways to do this?

Upvotes: 0

Views: 562

Answers (2)

Jon Gauthier
Jon Gauthier

Reputation: 25572

Something like the query below should fit. If you can give me any more details on what / how you wish to query I can make this SQL more specific. This current query selects users whose signup_date was 30 or more days ago:

SELECT * FROM users WHERE DATE_ADD(signup_date, INTERVAL 30 DAY) <= NOW()

For further information:

Upvotes: 1

Kerrek SB
Kerrek SB

Reputation: 476980

Use the DATEDIFF function to return the difference between then and NOW() in days.

Upvotes: 2

Related Questions