I am working on an attendance software in asp.net, in it i have to make a report which will tell the user about the hours and everything…so far i have created the basic functionality of the system, i.e. the user can check in and check out…i am stuck at making the report…
I have to calculate the working hours for every month, so the user can compare his hours with the total hours…what i had in mind was to create a stored procedure which when given a month name and a year, returns an int containing working hours for that month….but i can seem to get at it….
so far i found out how to create a date from a given month and a date, and found out the last day of that month, using which i can find out the total days in month…now i cant seem to figure out how do i know how much days to subtract for getting the working days.
here’s the so far code..
declare
@y int,
@m int,
@d int,
@date datetime
set @y = 2012
set @m = 01
set @d = 01
----To create the date first
select @date = dateadd(mm,(@y-1900)* 12 + @m - 1,0) + (@d-1)
----Last Day of that date
SELECT DATEADD(s,-1,DATEADD(mm, DATEDIFF(m,0,@date)+1,0))
any help will be appreciated guys, thanks in advance….
The @theDate is any date on the month you want to calculate the work days. This approach does not take care about holidays.