Chuck Tomasi
Tera Patron

There are a couple things to remember when doing date/time operations.

  1. The system stores all date/time fields as UTC - or at least it believes it does.
  2. If you want to apply your local to the value retrieved from a field, use getDisplayValue(). 
  3. If you want UTC, use getValue()
  4. 2 and 3 also apply to setDisplayValue() and setValue(). 

Once you keep it straight in your head when a TZ is applied (e.g. display values) and when it is not (getValue()/setValue()) everything else becomes pretty easy.

 

Based your requirement, you want to take the value the user gave you, and strip the timezone - something like this:

 

// change user.date to whatever variable the user gave you

var gr = new GlideRecord('incident');

var date = new GlideDateTime();

date.setDisplayValue(user.date); // insert it in to the variable with TZ applied, so the internal value has no TZ

gr.addQuery('sys_created_on', '>', date);

 

Standard disclaimer: The following code is untested, requires review and potential modifications.

 

View solution in original post