How to check if the given date falls in current week and current month

Pratiksha Lang1
Kilo Sage

How to check if the given date falls in current week and current month

Using filter in encoded query as date on today or date on this month works as per the user time zone. But I want this be achieved via script and in IST time zone, I want to check if the date falls in current week or current month.

 

 

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

@Pratiksha Lang1 

in script get the start date of the week and end date of the week and also get current month

then you can compare

what script did you start with?

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Pratiksha Lang1 

check this

Get the beginning of the PROVIDED week in a GlideDate/GlideDateTime 

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader

@Ankur Bawiskar  I have written this in ACL and this is to check today's date as per the IST timezone similarly I want to check for this week and this month date according to that I want to make field editable. This is not working 

 

Restrict field on the basis of date using ACL

 

I have written write ACL on a field. This field should be editable if the date is today's date. if it is not current date then it should not allow the field to be edited.

I have written a script in ACL but not sure what is wrong here:

 

PratikshaLang1_0-1704350367392.png

 

 

Script :

 

//var answer = false;
var gdt = new GlideDate();
gdt.addSeconds(19800);

//var gr = new GlideRecord('x_amspi_smdrs_app_ola_score');
current.addQuery('frequency','Daily');
current.addQuery('ola_formula_score','down_time_minutes');
current.addEncodedQuery('score_number.state=1^ORscore_number.state=2');
current.addQuery('score_number.date',gdt);
current.query();
while(current.next())
{
    answer = true;
}

@Pratiksha Lang1 

check link I shared

Regards,
Ankur
✨ Certified Technical Architect  ||  ✨ 9x ServiceNow MVP  ||  ✨ ServiceNow Community Leader