Reputation: 5
I have following date range:
06/28/2014
06/29/2014
06/30/2014
07/01/2014
07/02/2014
I want to find smallest and largest date from the given date range. In this case 06/28/2014
and 07/02/2014
, respectively.
Upvotes: 0
Views: 111
Reputation: 2768
Here is answer, but next time try to find this easy answer by yourself:
DECLARE @datesTable TABLE (Dates DATE)
INSERT INTO @datesTable SELECT '06/28/2014'
INSERT INTO @datesTable SELECT '06/29/2014'
INSERT INTO @datesTable SELECT '06/30/2014'
INSERT INTO @datesTable SELECT '07/01/2014'
INSERT INTO @datesTable SELECT '07/02/2014'
SELECT MAX(Dates) AS MaxDate, MIN(Dates) AS MinDate
FROM @datesTable
Upvotes: 2