MYSQL date comparison
TO_DAYS(NOW()) - TO_DAYS(date_col) <= 30;
Our date_col must be in date time format, not a timestamp,
mysql> SELECT FROM_UNIXTIME (875996580);
-> '1997-10-04 22:23:00'
day(FROM_UNIXTIME(1277709862)) This returns the number of days that have passed since a certain timestamp
Get the day: day(FROM_UNIXTIME(add_time))
Get the month: month(FROM_UNIXTIME(add_time))
Get the year: year(FROM_UNIXTIME(add_time))
After getting the timestamp in the sql text Formatted as day, month, year: day(now()), month(now()), year(now())
where add_time is the field name, and the storage format is linux timestamp.
mysql> set @a = unix_timestamp();
Query OK, 0 rows affected (0.00 sec)
mysql> select @a;
+------------+
| @a |
+----------------+
| 1154942084 |
+----------------+
1 row in set (0.00 sec)
mysql> select from_unixtime(@a);
+---------------------+
| from_unixtime(@a) |
+---------------------+
| 2006-08-07 17:14:44 |
+---------------------+
1 row in set (0.00 sec)