Problem solve Get help with specific problems with your technologies, process and projects.

Function to return working days in a given month

Is there a function that will return the number of working days in a a given month? I am building a dashboard that queries my database, and I would like project sales based on a daily average MTD multiplied by the number of working days. This will change each month, so it would be nice to automate it.

This is a great question! A user defined function is a subroutine that encapsulates a piece of logic that can be reused. At a high level functions are either deterministic or nondeterministic which means they either return the same value with the same input values each time the function is called or not. SQL Server ships with a number of date and time functions that may address your needs. These functions include: GETDATE, DATEADD, DATEDIFF, DATEPART, etc. I would recommend reviewing these links to create your own user defined function to meet your specific application needs!

For More Information

Dig Deeper on Microsoft SQL Server Installation

Have a question for an expert?

Please add a title for your question

Get answers from a TechTarget expert on whatever's puzzling you.

You will be able to add details on the next page.

Start the conversation

Send me notifications when other members comment.

Please create a username to comment.