# Get # of days for week number X

Is there a way to get the total days or hours of each week of a month?

I am using WEEK_IN_MONTH() to get the week number but now I need something like HOURS_IN_WEEK() or DAYS_IN_WEEK() which I can use to generate hours. For example, looking at January. 1st week has 4 days = 96 hours. 2nd week has 7 days =168 hours, and so on, Last week has 6 days = 144 hours.

I need this in order to check SLAs for each week of the month.

• A regular week always has 7 days and 168 hours. Do you mean "Business Hours"? – Sebastian Kessel Jan 16 at 21:36
• No, when you pull data by week number you are not going to have the same number of days at the start and end of the month. Example: [Select SUM(field__c) FROM object__c where WEEK_IN_MONTH(CreatedDate) = 1]. In this scenario the first week of Jan only has 4 days. I need to know that for a formula in the code. – Matt M Jan 16 at 21:50
• That is not correct. According to documentation, WEEK_IN_MONTH is "The first week is from the first through the seventh day of the month.". So the first week will always have 7 days. developer.salesforce.com/docs/atlas.en-us.soql_sosl.meta/… – Sebastian Kessel Jan 16 at 22:49
• So the week will not have 7 days only at the end of the month.... But since you know the difference between 28 and the # of days in a month, the calculation should be easy. – Sebastian Kessel Jan 16 at 22:50