- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
03-19-2018 06:55 AM
There are a couple things to remember when doing date/time operations.
- The system stores all date/time fields as UTC - or at least it believes it does.
- If you want to apply your local to the value retrieved from a field, use getDisplayValue().
- If you want UTC, use getValue()
- 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.