Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Get total hours worked by employee from Time card

avinashb
Tera Contributor

Hi all,

I want to calculate the total hours in a month by any user individually from Time card table.

Can some one help me in that.

Regards,

Avinash Balli

5 REPLIES 5

christopheriron
Tera Expert

Hi Avinash,



You can get the total hours by month by adding a filter to only show the month then using list calculations by right clicking the header > configure > list calculations. This should then allow you to get the total value of all hours displayed at the bottom of the table.



Thanks,


Kishor kumar1
Mega Expert

var grTime = new GlideRecord('time_card');


grTime.addQuery('week_starts_onONThis month@javascript:gs.beginningOfThisMonth()@javascript:gs.endOfThisMonth()');


grTime.query();


var total = 0;


while(grTime.next()){


total = parseInt(grTime.monday) + parseInt(grTime.tuesday) + parseInt(grTime.wednesday)+parseInt(grTime.thursday)+parseInt(grTime.friday)+parseInt(grTime.saturday)+parseInt(grTime.sunday);


}


gs.addErrorMessage(total);



Regards,


Kishor


Thanks for the reply Kishore.



I want total hours in a month.


gyedwab
Mega Guru

Hi Avinash,



Are you trying to get this in script, or through reporting?