Join the #BuildWithBuildAgent Challenge! Get recognized, earn exclusive swag, and inspire the ServiceNow Community with what you can build using Build Agent.  Join the Challenge.

Need Script to add days to date field but days are there in dropdown list

malaisamy1
Kilo Contributor

Hi Guys,

I Have one more requirement. Could you please help me on this,

i have one date field called invoice_date where i have one more field called day_s

where day_s has dropdown values like 10,15, 30 so on.

my result field = invoice_date + day_s

that is it has to add the days whatever there in the day_s field. and stored in my result field.

result field is a date field.

Is it possible? any idea?

Thanks in Advance,

Malaisamy Ji

3 REPLIES 3

davidpanson
Mega Expert

You can't just add a date to days field with an operator like that. I believe this may work for you.



var date = new GlideDateTime(your date/time field here);  
var msAdded = current.(your days value).dateNumericValue();
date.add(msAdded);
answer = date.getValue();


This way you'll convert your standard days value into ms first then add it to your Date/time value and get the answer


Thank you so much david.....it works perfectly alright.... after changing this




answer = date.getDate();


Great!



Please remember to mark my answer correct/helpful or like if appropriate.