Click here to Skip to main content
15,889,527 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I need a query ,I am making Human resource management software ....
in the scenario a employee come in office & punch card & go home at the night & punch card but during the time he went for the break for some time after punch card & come again then punch card.

In simplicity he come office two times & go from office two time ,,I need the total workking times


the coloum for punch card is date time
actual_card_in_ time actual_card_out_time
Posted

You could sum the difference between the dates. Something like:
SQL
SELECT SUM(DATEDIFF(hour, actual_card_in_ time, actual_card_out_time))
FROM YourTable
WHERE ...
 
Share this answer
 
You can take the minimum time as the punch in time for a particular day.
You can take the maximum time as the punch out time for a particular day.

E.g. Punch in -
select min(logintime) from table where logindate = GetDate()

E.g. Punch out -
select max(logintime) from table where logindate = GetDate()
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900