- Post History
- Subscribe to RSS Feed
- Mark as New
- Mark as Read
- Bookmark
- Subscribe
- Printer Friendly Page
- Report Inappropriate Content
on 04-25-2022 01:06 AM
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.
- 5,191 Views
- Mark as Read
- Mark as New
- Bookmark
- Permalink
- Report Inappropriate Content
If you are in scope - use getDayOfWeekUTC instead of getDayOfWeekLocalTime