MySQL Date comparison
To_days (now ())-To_days (Date_col) <= 30;
Our date_col must be a DateTime 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 a timestamp has elapsed.
Date taken: Day (From_unixtime (add_time))
Get month: Month (From_unixtime (add_time))
Get Year: Years (From_unixtime (Add_time))
The SQL text inside gets the timestamp after formatting into days, months, years: Day (Today ()), Month (now ()), Year (now ())
Where Add_time is the field name, the storage format is the 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)
http://www.bkjia.com/PHPjc/326265.html www.bkjia.com true http://www.bkjia.com/PHPjc/326265.html techarticle MySQL Date comparison to_days (now ())-to_days (date_col) = 30; Our date_col must be a DateTime format, not a timestamp, MySQL SELECT from_unixtime ( 875996580); -' 1997-10-...