I am trying to get a understanding of calculating time?
I'll assume you mean how much actual time would be served on a particular sentence... it starts with "good time credits" that are applied to the sentence calculator a the beginning of the sentence. An inmate can only lose that good time by having behavior issues or breaking numerous rules. In federal you get 15%, state prison ranges from 15-30% good time. The difference with the state is that they're also dealing with a parole system too that can release an offender having done only one-third of their sentence.
Hi,  

  

check the following Code  

SQLCopy Code

```
-- Question 1 Answer
SELECT E.EmployeeID,E.Day, (E.TotalTime/60) 'TotalHours', (E.TotalTime%60) 'Minites'
FROM (SELECT EmployeeID,CONVERT(VARCHAR(10),FromTime,102) 'Day',SUM(DATEDIFF(mi,FromTime,ToTime)) 'TotalTime'
      FROM tblEmployeeTimeCard
      GROUP BY EmployeeID,CONVERT(VARCHAR(10),FromTime,102))E

-- Question 1&2 Answer
SELECT E.EmployeeID,E.Day, (E.TotalTime/60) 'TotalHours', (E.TotalTime%60) 'Minites',
CASE WHEN (E.TotalTime/60)>=6 THEN E.TotalTime - (30* ROUND((E.TotalTime/60*6),1))
     ELSE (E.TotalTime/60) END 'TotalWorkHours'
FROM (SELECT EmployeeID,CONVERT(VARCHAR(10),FromTime,102) 'Day',SUM(DATEDIFF(mi,FromTime,ToTime)) 'TotalTime'
      FROM tblEmployeeTimeCard
      GROUP BY EmployeeID,CONVERT(VARCHAR(10),FromTime,102))E
```
  

  

For ur Question 2, I am not getting. give some more details about that. if possible send some sample data. if access over lap like (From date is 2013 -04-05 11:55:00PM to 2013-04-05 19:10:00PM)  

then we can't able to fine the time difference. So check the code for Question No 1 and give the feedback.  

  

Regards,  

GVPrabu what’s your day rate. Can you show the calculate function that you've wrote so far? answer: `1.00` in the latest models of tvs jupiter, we can set the time. let me explain the... amy takes an hour so she does
1/60 of yhe job per minute
father takes 30 mins so he does
1/30 of the job per minute
 
together they complete
1/60 + 1/30 per minute 
or 3/60 of the job per minute
 
(3/60)x = 1
x = 60/3
x = 20 minutes not understood actually. plz clarify in detail its kind difficult to understand in my POV but not impossible  

imagining it while reading


can you show some codes? or samples on what you want to achive? Use [UNIX\_TIMESTAMP](https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-DateFunctions) function to convert timestamps to seconds, then subtract:



```
select UNIX_TIMESTAMP('20190102 02:14:18','yyyyMMdd HH:mm:ss') -
       UNIX_TIMESTAMP('20190102 00:01:05','yyyyMMdd HH:mm:ss');

```

Returns:


`7993` seconds. 


Difference in `'HH:mm:ss'` format:



```
select from_unixtime(UNIX_TIMESTAMP('20190102 02:14:18','yyyyMMdd HH:mm:ss') -
       UNIX_TIMESTAMP('20190102 00:01:05','yyyyMMdd HH:mm:ss'), 'HH:mm:ss');

```

Returns:



```
02:13:13

```