How can I convert string date field to Date field
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2022 09:00 PM
Hi,
We are getting date from string field (text box , eg : 2022-06-28 ) and want to convert it to date field. We are getting answer in string format and want to set this value into date format (course_date). Please help.
var emailID = g_form.getValue('user_email_address__completion');
//alert(emailID);
//Type appropriate comment here, and begin script below
var ga = new GlideAjax('getCompletionDate');
ga.addParam('sysparm_name', 'getCompletionDate');
ga.addParam('sysparm_id', emailID);
ga.getXML(setDate);
function setDate(response) {
var answer = response.responseXML.documentElement.getAttribute("answer");
//alert(answer);
//g_form.setValue('course_completion_date', ga.getAnswer());
// var gdt = new GlideDate(answer);
// alert(gdt);
// g_form.setValue('course_completion_date', ga.getAnswer());
g_form.setDisplay('course_date',ga.answer());
g_form.setValue('course_date', ga.answer());
}
Thanks,
- Labels:
-
Service Catalog
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2022 09:12 PM
Hi @reddy8055,
Try this in Script include -
var str = this.getParameter("sysparm_id");;
var date = new GlideDateTime(str);
return date.getDate();
Thanks,
Sagar Pagar
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-27-2022 06:25 AM
Thanks,
How can I add in this script include?
getCompletionDate: function(current) {
var retVal4 = "";
var emailID = this.getParameter('sysparm_id');
gs.log(" ***Email: " + emailID);
var car = new GlideRecord("u_vta");
car.addQuery("u_email_id", emailID);
car.query();
if (car.next()) {
gs.log(" ***Course Completion Date ");
retVal4 = car.u_course_completed_date;
gs.log(" ***Course Completion Date, retVal4: " + retVal4);
}
return retVal4;
},
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-26-2022 09:22 PM
HI,
var num=this.getParameter("sysparm_id");//'2022-06-28';
var num1=new GlideDateTime(num);
return num1;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-20-2022 08:03 AM
I can't provide you with a step - with the aid of - step system, but you will want to get your arms dirty with the widget link. The Capacity Planning Console is a Portal Page with widgets.