Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 how to find out no of sunday in a month

Author  Topic 

imranabdulaziz
Yak Posting Veteran

83 Posts

Posted - 2008-04-30 : 01:44:04
Hi,
i am using sql server 2005.
i want to know how to find no of sunday in a month(in any month)

Thank you.

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-30 : 02:10:22
Never less than 3 and never more than 5



E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2008-04-30 : 02:11:58
[code]SELECT YEAR_MONTH,
SUM(CASE WHEN WEEKDAY_NAME = 'SUN' THEN 1 ELSE 0 END) AS Sundays
FROM F_TABLE_DATE('20080101', '20081231')
GROUP BY YEAR_MONTH[/code]


E 12°55'05.25"
N 56°04'39.16"
Go to Top of Page
   

- Advertisement -