Another timesheet calculation question





Hello Everyone,

 

like many here, i am a newbie to the world of Javascript and im having a hard time getting this calculation working.

 

I have a sheet, where a column of fields is entered manually with a time value, say 1:43.  At the bottom of the page is a "total" field which i have managed to get to tally all the fields above it, except there is a problem, I cant get hours more than 24, so if the tally is greater than 24 hrs it produces an error.  Also, i am unable to enter a time of greater than 23:59 in any feild.

 

This is a problem , as engine run times are in hours and minutes, and not in days, hours and minutes.

 

These are the codes ive found to work in a basic way, but any help in getting it to displah hours of greater than 24 would be appreciated.

 

Jay


```
// custom calculations script for the total time field
// array of fields to total
var aFields = new Array("Time.0", "Time.1", "Time.2", "Time.3", "Time.4", "Time.5", "Time.6");
// define total accumulated minutes
var nSum = 0;
// variable for time string value of a field
var sTime;
// convert the time fields to minutes and total the minutes
for(i = 0; i < aFields.length; i++) {
// get the time string for the i element field name
sTime = this.getField(aFields[i]).valueAsString;
// convert blank fields to 00:00;
if(sTime == "") sTime = "00:00";
// convert time string to minutes and sum
nSum += HHMM2Min(sTime);
} // end loop through the fields
// format sum of minutes
event.value = Min2HHMM(nSum);
// end of custom calculation field
```

```
// document level functions
function HHMM2Min(cTime) {
// convert time formatted as HH:Mm to minutes
// spit input time string to an array
var aHHMM = cTime.split(":");
// define total minutes
var nMinutes = 0;
// convert 0 element from hours to minutes
nMinutes = aHHMM[0] * 60;
// add minutes from 1 element of array
nMinutes += Number(aHHMM[1]);
// return the time value as minutes
return nMinutes;
} // end HHMM2Min
function Min2HHMM(nMinutes) {
// convert minutes to HH:MM string
// return formatted time string
return util.printf("%,001.0f:%,202.0f", Math.floor(nMinutes / 60), nMinutes % 60);
} // end Min2HHMM
// end document level functions
```
You can set the format of the fields to "None".
how about this?

fn write\_some\_content(&mut self, hour: u32) -> result<(), std::io::error> {

if self.current\_hour != hour {

if let some(writer) = self.current\_file.as\_mut() {

writer.flush()?;

}

self.current\_file = none;

self.current\_hour = hour;

}

… 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 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

``` hi [@ashish.tyagi](/u/ashish.tyagi), hope below solution will work for you

assign

var\_int\_count = list\_mailmessages.where(function(x) convert.todatetime(x.date).tostring(“dd/mm/yyyy”)=date.now.tostring(“dd/mm/yyyy”)).count [image] akanksha\_varshney:

(convert.tostring(date\_created\_hs.substring(0,10)).equals(convert.tostring(date\_created\_cchq.substring(0,10)))) or (date\_created\_hs <> “”)

hey,

try with the following one,

(convert.tostring(date\_created\_hs.substring(0,10).trim).equals(convert.tostring(date\_created… Reason: `s` starts at 1 and is incremented on first call, but is never reset. On seconds and subsequent calls `s` no longer starts at 1. `s` is actually unnecessary as you can use the loop counter `i` instead.



A more conventional way to do this sort of thing would be with a single function, not embedded in an object, and to control the detailed behaviour by passing parameter(s).



```
function loadGame(level){
	var values;
	switch(level){
		case 'hard':
			values: [7,8,9],
		break;
		case 'normal':
			values: [4,5,6],
		break;
		default://easy
			values: [1,2,3],
	}
	for(i=0;i<=this.values.length;i++){
		document.getElementById('n'+i).innerHTML=this.values[i];
	}
}
```


```
<div id="n0"></div>
	<div id="n1"></div>
	<div id="n2"></div>
	<input type="button" value="easy" onClick="loadGame('easy')"/>
	<input type="button" value="normal" onClick="loadGame('normal')"/>
	<input type="button" value="hard" onClick="loadGame('hard')"/>
```

**Airshow** 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 In the end, I found this query, which groups the way it should:  
  

```
SELECT 
 FROM_UNIXTIME( TRUNCATE( UNIX_TIMESTAMP( tstamp )/900, 0 ) * 900 ) as h,
 AVG( amount ) as v
FROM 
transactions
GROUP BY 
h
ORDER BY 
 h desc
LIMIT
 24
``` > 
> i want to create ap application which generates popup alerts at the day of event ocurs as well as a day before the event will occur in a specific time interval as well.. events are stored in database and they are all date fields .. so i want to link those fields to create popups .. help me .
> 
> 
> 


In order to help you, you must first provide us with what you have achieved. We do not write code for you, simply correct and enlighten on mistakes. hello [@scotttpa](/u/scotttpa),

for cumulative totals instead of selecting “all” replace it with “allselected” and also replace the ‘recurring subscriptions’[subscription start date]) with the dates table. so your code should be like this overall -

abcs cumulative started to date =

calculate ( [abc order count …