Skip to content

Commit a63a20a

Browse files
authored
Create README.md
1 parent 02b34a8 commit a63a20a

File tree

1 file changed

+23
-0
lines changed
  • Core ServiceNow APIs/GlideDateTime/Check Record Creation over 90 days and output age

1 file changed

+23
-0
lines changed
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Usecase**:
2+
This piece of code can be used to check whether a record was created more than 90 days ago or not.
3+
It returns an output of true/false as well as the actual age (in days) of the record.
4+
5+
**Type**:
6+
Background Script
7+
8+
**How it works**:
9+
There is a pastDateString variable which can contain a date-time which you received by querying any particular record's sys_created_on field or any other relevant field.
10+
In the actual code I have hard-coded a value to be used as an example.
11+
-There are two gliderecord objects to store the current date as well as past date
12+
-GlideDateTime.subtract() is used to calculate the time difference as a GlideDuration object
13+
-The time duration in milliseconds is converted to days by dividing with 86400000(milliseconds in a day)
14+
-Comparison is done between the results
15+
-The final age of the record and true/false result of the comparison is the output.
16+
[Note: Output may vary according to timezones]
17+
18+
**Example**:
19+
pastDateString = 2025-05-01 10:00:00
20+
Output:
21+
22+
Record Age (Days): 165
23+
Older than 90 days? true

0 commit comments

Comments
 (0)