943,983 Members | Top Members by Rank

Ad:
  • ColdFusion Discussion Thread
  • Unsolved
  • Views: 6056
  • ColdFusion RSS
Nov 1st, 2006
0

finding duration worked between time ranges from login and logout time

Expand Post »
Hi Folks
I am in a difficult situation right now. Please help me.
There are several stores and several employees.
employees can work in multiple stores and stores have multiple employees
the time they work are calculated based on the time they log in and log out.
for this purpose there is a logins table which has following fields.
emp_id, store_id, login_time, logout_time
emp_id stores the employee id
store_id stores the store id
login_time will have the time of logging in by the employee (datetime)
logout_time will have the time of logging out by the employee (datetime)
there is a manager for every store. he/she will be concerned with the store.
what I need is a way to find out the total working time in minutes for a store
within a particular date range
for eg. from 11/1/06 7:30 am to 11/5/06 6:pm for store id 7
i want the system to return something like
employee_id time
-------- -----
45 780 minutes
34 327 minutes

-Ramesh
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
rameshsambu is offline Offline
8 posts
since Oct 2006
Mar 23rd, 2007
0

Re: finding duration worked between time ranges from login and logout time

Hi Folks
I am in a difficult situation right now. Please help me.
There are several stores and several employees.
employees can work in multiple stores and stores have multiple employees
the time they work are calculated based on the time they log in and log out.
for this purpose there is a logins table which has following fields.
emp_id, store_id, login_time, logout_time
emp_id stores the employee id
store_id stores the store id
login_time will have the time of logging in by the employee (datetime)
logout_time will have the time of logging out by the employee (datetime)
there is a manager for every store. he/she will be concerned with the store.
what I need is a way to find out the total working time in minutes for a store
within a particular date range
for eg. from 11/1/06 7:30 am to 11/5/06 6:pm for store id 7
i want the system to return something like
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pankaj_chetry is offline Offline
1 posts
since Mar 2007
Mar 25th, 2007
0

Re: finding duration worked between time ranges from login and logout time

Might a SQL query like this work?

SQL Syntax (Toggle Plain Text)
  1. SELECT employee, SUM(login_date_time-logout_date_time) as empTime
  2. FROM login_log_table
  3. WHERE login_date_time BETWEEN X AND Y
  4. GROUP BY employee
Reputation Points: 12
Solved Threads: 0
Light Poster
Memento is offline Offline
30 posts
since Jan 2007
Mar 30th, 2007
0

Re: finding duration worked between time ranges from login and logout time

Hi Ramesh,

This example might be more complex than what you need, but it should give you a starting point. Caveat - This example only counts the time that fall within @start and @end period. So for example if an employee started work at 11/1/06 6:30AM, and you entered a @start date of 11/1/06 7:30 am, the hour between 6:30AM and 7:30AM would not be counted.

ColdFusion Syntax (Toggle Plain Text)
  1.  
  2. --- counts ONLY the time worked between @start and @end
  3. SELECT e.emp_id,
  4. SUM
  5. (
  6. DATEDIFF
  7. (n,
  8. CASE WHEN login_time < @start THEN @start ELSE login_time END,
  9. CASE WHEN logout_time > @end THEN @end ELSE logout_time END
  10. )
  11. )
  12. AS TotalTimeWithinDateRange
  13. FROM LoginTable lt
  14. INNER JOIN Store s ON lt.store_id = s.store_id
  15. INNER JOIN Employee e ON lt.emp_id = e.emp_id
  16. WHERE s.store_id = @store_id AND
  17. (
  18. (lt.login_time BETWEEN @start AND @end) OR
  19. (lt.logout_time BETWEEN @start AND @end) OR
  20. (lt.login_time <= @start and logout_time >= @end)
  21. )
  22. GROUP BY e.emp_id
Reputation Points: 10
Solved Threads: 0
Unverified User
cfAllie is offline Offline
28 posts
since Mar 2007

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in ColdFusion Forum Timeline: hiding runtime dialog "window" for jrunsvc.exe
Next Thread in ColdFusion Forum Timeline: Need help with n-tier looping





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC