0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

[ServiceNow] GlideSchedule APIで営業日計算する

Last updated at Posted at 2023-02-09

指定日からX営業日後の日付を計算する

きっかけ

インシデントの解決日時のX営業日後を取得する必要があった

方法

GlideSchedule API のaddメソッドを使えば期待するものは取れそう

前提条件

Tokyoで実施
営業日カレンダーはOOTBの8-5 weekdays excluding holidaysを使用

サンプルコード

    var sch_id = "090eecae0a0a0b260077e1dfa71da828"; // 8-5 weekdays excluding holidays
    var gdt = new GlideDateTime("2023-02-09"); // 元の日付
    var duration = 5; // 営業日数
    var sched = new GlideSchedule(sch_id, "Asia/Tokyo");
    var dur = new GlideDuration(60 * 60 * 9 * 1000 * duration); // 8-5時なので1日を9時間として間隔を定義
    var result = sched.add(gdt, dur);
    gs.info(result);

実行結果

*** Script: 2023-02-16 00:00:00

参考

GlideSchedule API(ServiceNow Developer)

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?