I have exhausted my searches looking for a solution to this MySQL date calculation. My client wants to know how many deals were done in the past week, month and year.
It is a SQL based script (but in MySQL language) I am busy with, so don’t bother with the Select, From etc.
The datetime_created field (in the script) is already in UnixTime, while the timestamp(now) is used to calculate current date minus 7 days.
As the formula result can be negative as well, I only require the result between 0.01 and 7.
My formula for the past week is listed below. Any ideas?
(registrations.datetime_created -unix_timestamp(now())-604800)/86400
The Where clause was not accepted at all, and I had to change some logic.Thanks all, but the final script was a concoction from everyone, and is as follows: