How to get the maxmum date and minimum date in mysql using only one sql query?
The SQL MIN() and MAX() FunctionsThe MIN() function returns the smallest value of the selected column. The MAX() function returns the largest value of the selected column.
MySQL SELECT statement is used to retrieve rows from one or more tables. The statement can also include UNION statements and subqueries. SELECT statement is used to fetch rows or records from one or more tables.
The MySQL BETWEEN operator is inclusive. For example, when you use the MySQL BETWEEN operator to retrieve the books whose price is in the range between 50 and 90, the result retrieves all of these books, including those whose price equals 50 or 90.
How do I find the smallest date in MySQL? MySQL MIN() Function The MIN() function returns the minimum value in a set of values.
SELECT MIN(date_col), MAX(date_col) FROM table_name
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With