- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-25-2016 02:31 AM
Hi , I have a scheduled job which pulls the end date of record and uses it to create the start date of the next period. However when I use the glidedatetime function addDaysUTC(1) it's adding 1 day to multiple variables , as below ;
var endDCP = cp.u_enddate.getGlideObject();
gs.info('**** JJ Says endDCP is : ' + endDCP);
var sDate = cp.u_enddate.getGlideObject();
gs.info('**** JJ Says sdate is : ' + sDate);
sDate.addDaysUTC(1);
gs.info('**** JJ Says sDate Plus 1 is : ' + sDate + ' and endDCP is ' + endDCP);
log output ;
25-01-2016 10:23:14 25-01 10:23 6 minutes ago | Information | **** JJ Says sDate Plus 1 is : 2016-01-16 and endDCP is 2016-01-16 | *** Script | |
25-01-2016 10:23:14 25-01 10:23 6 minutes ago | Information | **** JJ Says sdate is : 2016-01-15 | *** Script | |
25-01-2016 10:23:14 25-01 10:23 6 minutes ago | Information | **** JJ Says endDCP is : 2016-01-15 |
i've tried swapping the order of the variables and putting endDCP after the addDaysUTC statement but it still behaves the same. Can anyone spot my deliberate mistake please.
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2016 07:24 AM
After some assistance from a colleague it turns out the issue was down to me not instantiating each variable as a new GlideDateTime, changing this also required a change to using getDisplayValue .. but the long and the short of it is, issue resolved .. pasted the update code in below as that may make more sense 😉
var endDCP = new GlideDateTime(); | |
var sDate = new GlideDateTime(); | |
endDCP.setDisplayValue(cp.u_enddate.getDisplayValue()); | |
sDate.setDisplayValue(cp.u_enddate.getDisplayValue()); | |
sDate.addDaysUTC(1); |
which now results (correctly) in the following;
JJ Says sDate Plus 1 is : 2016-01-16 00:00:00 and endDCP is 2016-01-15 00:00:00
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-28-2016 07:24 AM
After some assistance from a colleague it turns out the issue was down to me not instantiating each variable as a new GlideDateTime, changing this also required a change to using getDisplayValue .. but the long and the short of it is, issue resolved .. pasted the update code in below as that may make more sense 😉
var endDCP = new GlideDateTime(); | |
var sDate = new GlideDateTime(); | |
endDCP.setDisplayValue(cp.u_enddate.getDisplayValue()); | |
sDate.setDisplayValue(cp.u_enddate.getDisplayValue()); | |
sDate.addDaysUTC(1); |
which now results (correctly) in the following;
JJ Says sDate Plus 1 is : 2016-01-16 00:00:00 and endDCP is 2016-01-15 00:00:00