Hello,
I have some total values, I want to calculate percenatge of these Total Values.
I want to divide the total with No. Of working Days Excluding Saturdays and Sundays in a given period.
How to calculate the Total Number of working Days in a given period . Let us say If i give the period as 08/01/2008 to 08/15/2008, I want total number of working days as 11.
Please help me
4 11186
Hi,
Try the following query: -
SELECT Count(Date_Column)
-
FROM Table_Name
-
WHERE Date_Column BETWEEN '08/01/2008' AND '08/15/2008'
-
AND Datename(weekday, Date_Column) NOT IN ('Sunday','Saturday')
-
-
Thanks
I don't have any Date column.
I just want to calculate the Total No. Of Working Days in the Given Period
I don't have any Date column.
I just want to calculate the Total No. Of Working Days in the Given Period
Hi,
Try the following one -
Declare @startdate datetime
-
Declare @enddate datetime
-
-
Set @startdate = '08/01/2008'
-
Set @enddate = '08/15/2008'
-
-
SELECT Count(Date)
-
FROM ( Select dateadd(dd,number,@startdate) as Date
-
from master.dbo.spt_values
-
where master.dbo.spt_values.type='p' AND dateadd(dd,number,@startdate)<=(@enddate)
-
) AS T
-
WHERE Datename(weekday, T.Date) NOT IN ('Sunday','Saturday')
-
-
Thanks
I found this on another site:
select @weekDaysInPeriod = (
DATEDIFF(DAY, @StartDate, @EndDate) + 1
+ (DATEDIFF(DAY, '17530101', @StartDate) + 1) / 7 * 2
- (DATEDIFF(DAY, '17530101', @EndDate) + 1) / 7 * 2
- CASE DATEDIFF(DAY, '17530101', @StartDate) % 7
WHEN 6 THEN 1
ELSE 0
END
- CASE DATEDIFF(DAY, '17530101', @EndDate) % 7
WHEN 5 THEN 1
ELSE 0
END
)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: JP SIngh |
last post by:
Hi All
I need to calculate the number of working days between the two dates entered
on an ASP page. I am not that great a coder in ASP and was wondering if
someone can help.
Basically the...
|
by: CrystalDBA |
last post by:
I am using SQL Server 2000. I need to query my database for all the
contracts that came in during a certain time frame (user is prompted
for reportingperiodid).
Table - Periods
Fields -...
|
by: |
last post by:
Hello,
I am hoping someone else has thought about a date time calculation i need to
perform.
I would like to be able to calculate the number of "working minutes" between
2 dates, given my...
|
by: Mayhem05 |
last post by:
I'm hoping someone can guide me on solving this vexing problem I have
with a database I built to track a projects. I'm using MS Access 2003
and here are the basics: the database is designed to...
|
by: foleyflint |
last post by:
Hello, I'm trying to calculate the interest from a bankaccount which is displayed in a text file as followed:
9 2 345
3 3 300
etc. (there are 19 lines in total)
the first number...
|
by: Sam |
last post by:
Hi,
I use C# in my ASP.NET projects. Here's what I need to do: I want to add x
business days to a given date i.e. add 12 business days to today's date. What
is the best, fastest and most...
|
by: khicon73 |
last post by:
Hello All,
I would like to calculate weeknumber and period from first day of the week (sunday) and last day of the week (saturday) and week number falls from 1 to 52 only. If week number >= 53 then...
|
by: Tommy Jakobsen |
last post by:
Hi.
Is there a method in .NET that takes "year" as an argument and returns the total
number of weeks in that year? For culture da-DK (Danish).
Thanks in advance.
Tommy.
|
by: FishVal |
last post by:
IMHO, the following is not a how-to-do instruction to solve a particular problem but more a concept-proof stuff demonstrating possibilities of SQL.
So, let us say the problem is to calculate...
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
| |