Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Average Time
Message
 
 
To
24/07/2009 10:26:43
General information
Forum:
Microsoft SQL Server
Category:
Other
Title:
Environment versions
SQL Server:
SQL Server 2005
Application:
Desktop
Miscellaneous
Thread ID:
01414190
Message ID:
01414193
Views:
42
>I need to find the average "check-in time" of an employee with a month period.
>The check-in date is stored in datetime field.
>How can I calculate the average?

select EmployeeID, avg(CheckInTime) as Avg_CheckInTime from CheckIns where CheckInTime between @StartOfTheMonth and @EndOfTheMonth group by EmployeeID

Pass a month number and calculate the @Start and @End dates.

See http://www.sql-server-helper.com/functions/get-last-day-of-month.aspx (for example) of how to get first and last date of the month.
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform