How to create report on monthly or yearly (time_card table) in ServiceNow?

samanthredd
Tera Contributor


I am aiming to generate a report in ServiceNow that presents data on a monthly or yearly basis for the past 12 months. However, when utilizing the timecard table, the information is currently limited to a weekly format only.

3 REPLIES 3

Sachin Bhadana
Tera Expert

Hi @samanthredd ,

 

Under the reporting feature, if you don’t have a month field, you can create a calculated field or use start date and format it.

Or else you can also create a database view with a calculated column in the view to extract the month and year from the week starts date. Then create a report on this database view grouped by month.

 

Please accept this solution and mark this as helpful if you find it useful.

 

Regards,

Sachin

Community Alums
Not applicable

Yeah, the timecard table in ServiceNow is structured weekly by default, so if you're trying to create a monthly or yearly report, you won’t get that directly out of the box. But there’s a workaround.

What you can do is pull the timecard records for the last 12 months and then group them by month or year using a script. Here’s a quick example you can run in a background script to get total hours per month:

 

var monthlyHours = {};

var gr = new GlideRecord('time_card');
gr.addEncodedQuery('start_dateONLast 12 months@javascript:gs.beginningOfLast12Months()@javascript:gs.endOfThisMonth()');
gr.query();

while (gr.next()) {
    var start = new GlideDateTime(gr.getValue('start_date'));
    var year = start.getYearLocalTime();
    var month = (start.getMonthLocalTime() + 1).toString().padStart(2, '0'); // Month is zero-based
    var key = year + '-' + month;

    if (!monthlyHours[key]) {
        monthlyHours[key] = 0;
    }

    monthlyHours[key] += parseFloat(gr.getValue('hours'));
}

for (var m in monthlyHours) {
    gs.print(m + " → " + monthlyHours[m] + " hrs");
}

 

This will print something like:

 

2024-07 → 162 hrs
2024-08 → 145 hrs
...
2025-06 → 120 hrs

 

If you want to show this in a report or dashboard, you might need to either:

  • Store this data in a custom table via scheduled job, then report on it.

  • Or use Performance Analytics if your instance has it — that makes monthly trend reports easier.

Bhavya11
Kilo Patron

Hi @samanthredd ,

 

Here is a step by step process to create your reports

Project hours per month

Data stage:

Bhavya11_0-1751357540066.png

Type Stage:

Choose column chart in Time Series section

Bhavya11_1-1751357564751.png

Configure :

Bhavya11_2-1751357606145.png

Style stage:

Bhavya11_3-1751357655824.png

Also filter with state processed to only look at processed time cards

Run the report and it will look something like below

 

Bhavya11_4-1751357714245.png

 

If this information proves useful, kindly mark it as helpful or accepted solution.

Thanks,

BK