Welcome to Community Week 2025! Join us to learn, connect, and be recognized as we celebrate the spirit of Community and the power of AI. Get the details  

Using variable to set due date on task ticket - date is setting to the variable - 1 day. Why?

NancyS1
Tera Expert

I have a Due Date field on my catalog form, named csc_due_date. In the workflow on the Create Task activity, I'm using the due date on the task ticket. I'm using this script:

task.due_date = current.variable_pool.csc_due_date;

The due date field gets updated, but it's off by a day. For example, if I pick 1/15/2022 as my due date on the form, the ticket gets a due date of 1/14/2022. 

I don't understand why I'm off by a day. Any help appreciated.

1 ACCEPTED SOLUTION

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

possibly because of timezone

use this

task.due_date = new GlideDateTime(current.variable_pool.csc_due_date);

Regards
Ankur

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

View solution in original post

8 REPLIES 8

Ankur Bawiskar
Tera Patron
Tera Patron

Hi,

possibly because of timezone

use this

task.due_date = new GlideDateTime(current.variable_pool.csc_due_date);

Regards
Ankur

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

Thanks @Ankur Bawiskar - I think you might be correct about the timezone. When I use your suggested script, the due date field remains blank. Since my original code at least puts a date in the field, I tried using GlideDateTime addDays to add a day to my variable, but that also leaves the field blank. 

Am I using GlideDateTime incorrectly or is it not possible to use it in a workflow script?

Hi,

try to debug by adding log statements

Regards
Ankur

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

Hi Ankur,

 

Could you advise where this script needs to be used in order to achieve the outcome. I am facing similar issue and looking to implement your suggestion.

 

Regards,

Naresh