- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2018 12:34 AM
Hi All,
Here i am trying to add 1 year and fetch result into u_next_verification_date. when i execute in the message it shows correct , but in the field value showing wrong.
Any help is highly appreciated.
Vass
When i update the record it is showing the correct date values in the message below.
But when i open the record and check the field value it showing wrong. (Highlighted field).
Also i wish the date value should be the blue rounded one hours/minutes/seconds.
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-08-2018 03:51 AM
Try Below Code,Its working fine
var gr = new GlideDateTime();
var gr1=gs.yearsAgo(-1);
var date= gr1.split(' ')[0];
var time=gr1.split(' ')[1];
var gd = new GlideDate();
gd.setValue(date);
date=gd.getByFormat('dd/MM/yyyy');
gr1=date+' '+time; //gr1 is your converted format
gs.addInfoMessage(gr1);
current.u_next_verification_date =gr1;
current.update();
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2018 12:39 AM
Hi Vaas,
That's because your system date time format is dd-mm-yyyy HH:MM:SS but the calculation you are doing is using system format i.e. YYYY-MM-DD HH:MM:SS.
you need to convert it into that format and then do the calculation
Mark Correct if this solves your issue and also mark Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2018 03:45 AM
Thanks Ankur.
May i know how to change that? I have tried different formats not working
Regards
VASS
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2018 07:24 AM
Hi,
this is not the date time format problem.
Actually i am also facing same problem so i first i split date and time .
i added splited date in glidedatetime object .
then added 1 year to the date .
then combined date having 1 year added with time which i splited from the intial date .
so it is giving correct result.
so please use below code as i executed it and it's working .
var date ="2016-10-12 07:11:23";//here assign your actual date time and then split in two string
var split_date =date.split(' ');
var gd =new GlideDateTime();
gd.setDisplayValue(split_date[0]);
gd.addYearsLocalTime(1);
var demp= gd.getDate();
var date_time = demp +" "+split_date[1];
gs.print( " date time after adding 1 year in actual date is "+date_time +" "+"only date is"+demp);
Mark this answer as Correct and Helpful .
Regards,
Manjusha Bangale

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-03-2018 04:50 AM
Hi,
Remove getDisplayValue from the code and give a try.