logo

NJP

How to check if today is weekend or weekday? How to detect weekend days?

Import · Apr 25, 2022 · article

Hello ServiceNow Ninjas,

Date functions can be tricky, and many times I came across to find if today is a weekend or weekday?

There can be many ways, but I am showing one which uses ServiceNow classes & functions.

You can watch the video which has line by line explanation - Click Here

Also please find the script below for your reference -

-------------------------------------------------------------------------------------

var gcdt = new GlideDateTime("2022-04-24 12:02:00"); // fetch date

gs.print(gcdt);

var day =gcdt.getDayOfWeekLocalTime(); // return the local day number

if(day == 7 || day == 6)

gs.print("weekend");

else

gs.print("weekday");

------------------------------------------------------------------------------------

We are committed to providing easy and fast solutions.

Our training Videos - Click Here

Mark helpful, If this post saved your time.

View original source

https://www.servicenow.com/community/now-platform-articles/how-to-check-if-today-is-weekend-or-weekday-how-to-detect/ta-p/2306151