Schedule a report to run in specific days of the year.

jlference
Tera Contributor

Hello:

I have a report that should be run on specific days of the year, namely, the first day of January, April, July, October.  I need help with developing the script that I could add to the Conditional setting in the report.

 

Many thanks in advance for your assistance.

2 REPLIES 2

pavani_paluri
Giga Guru
Giga Guru

Hi @jlference ,

 

You can use the advanced condition in scheduled report and use below script to check for first day of required months:

 

var today = new GlideDateTime();
var month = today.getMonthUTC() + 1; // getMonthUTC() is zero-based
var day = today.getDayOfMonthUTC();

// Run only on the 1st of Jan, Apr, Jul, Oct
return day == 1 && (month == 1 || month == 4 || month == 7 || month == 10);

 

Mark it helpful if this helps you to understand. Accept solution if this give you the answer you're looking for
Kind Regards,
Pavani P

vignesh parthib
Tera Expert

Hi @jlference 

 

simple script condition you can use to check whether today's date matches the 1st of Jan, Apr, Jul, or Oct:

Please refer Screen shot:

 

Example Script:

var today = new Date();

    var month = today.getMonth(); // 0 = January, 3 = April, 6 = July, 9 = October

    var day = today.getDate();    // 1 = first day

 

    // Check if today is the 1st of Jan, Apr, Jul, or Oct

    if (day === 1 && (month === 0 || month === 3 || month === 6 || month === 9)) {

        return true;

    }

 

    return false;

vigneshparthib_0-1759334971531.png

Thanks,
Vignesh
"If this solution resolves your issue, kindly mark it as correct."