Finding the minimum date for every month in a table.
Hi, I have a table that stores the date for every day of the month. I need to get the minimum date for every month thats in the table. So, my table shows the report as below 7/1/2008 7/28/2008 7/29/2008 7/30/2008 7/31/2008 8/4/2008 8/5/2008 8/6/2008 8/7/2008 I just need to pick the minimum date in those months meaning i just need to see 7/1/2008 and 8/4/2008 in my query result. How do i do it? Thank you.
October 23rd, 2010 9:45pm

One method: SELECT MIN(MyDate) AS MyDate FROM dbo.MyTable GROUP BY DATEADD(month, DATEDIFF(month, '19000101', MyDate), '19000101'); Dan Guzman, SQL Server MVP,
Free Windows Admin Tool Kit Click here and download it now
October 23rd, 2010 9:57pm

Perfect. Thank you.
October 23rd, 2010 10:11pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics