Reputation: 55633
How to get the maxmum date and minimum date in mysql using only one sql query?
Upvotes: 36
Views: 65640
Reputation: 400
Very similar to Icarus's answer, but I prefer to rename the columns to something meaningful like:
SELECT MIN(date) AS start, MAX(date) AS finish FROM table
Upvotes: 1
Reputation: 5661
JUST IN CASE someone came here looking for minimum and maximum supported dates like I did... here's the answer to your question :)
select
DATE('1000-01-01') MinDate,
DATE('9999-12-31') MaxDate
+------------+------------+
| MinDate | MaxDate |
+------------+------------+
| 1000-01-01 | 9999-12-31 |
+------------+------------+
Reference: https://dev.mysql.com/doc/refman/5.5/en/datetime.html
Upvotes: 23