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 2008 Forums
 Transact-SQL (2008)
 how to get number of weeks in a month

Author  Topic 

julius.delorino
Starting Member

29 Posts

Posted - 2012-06-05 : 11:19:11
good sir, may i ask how to get the number of weeks in a month:
example :


Month number_of_weeks
Feb 4
Mar 5
Apr 4
May 4

how can you write this in SQL?
thanks to all!

nigelrivett
Master Smack Fu Yak Hacker

3385 Posts

Posted - 2012-06-05 : 11:40:53
How do you define the number of weeks in a month? Number of days divided by 7?

==========================================
Cursors are useful if you don't know sql.
SSIS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

Michael Valentine Jones
Yak DBA Kernel (pronounced Colonel)

7020 Posts

Posted - 2012-06-05 : 12:34:47
You will have to provide an exact definition of the weeks and months for your organization before anyone can help you. Weeks and months are two different types of time periods.

Weeks are normally defined as 7 days starting on a particular day of week, but that varies widely from one organization to the next.

Months cannot be evenly divided into weeks, except for non-leap year Feb. Even the definition of month may vary form one organization to another.




CODO ERGO SUM
Go to Top of Page
   

- Advertisement -