
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2017 09:01 AM
I need to set the time portion of the field "stnd_req_date" which is a date/time field to the var "requesteddate" as you see below. The var "requesteddate" however is only a date field. Can someone show me how to set the time portion of the field to 5:00pm?
function onLoad() {
//Populate the variables with the parameters passed in the URL
//Use the 'getParmVal' function below to get the parameter values from the URL
var desc = getParmVal('sysparm_desc');
var wlist = getParmVal('sysparm_wlist');
var parent = getParmVal('sysparm_parent');
var requesterfor = getParmVal('sysparm_requester');
var requesteddate = getParmVal('sysparm_date');
var requestedby = g_user.userID;
g_form.setValue('requested_by',requestedby);
if(desc){
g_form.setValue('arDesc',desc);
g_form.setValue('stnd_req_add_info',desc);
}
if(requesterfor){
g_form.setValue('requested_for',requesterfor);
}
if(requesteddate){
g_form.setValue('stnd_req_date',requesteddate );
}
}
function getParmVal(name){
var url = document.URL.parseQuery();
if(url[name]){
return decodeURI(url[name]);
}
else{
return;
}
}
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2017 10:32 AM
So long as your date format is the same as the system's date format, you should be able to just add the appropriate time string. Given that the date format is YYYY-MM-DD and the time format is HH:MM:SS, here is the change you can make:
if(requesteddate){
var reqDateTime = requesteddate + ' 17:00:00';
g_form.setValue('stnd_req_date',reqDateTime);
}

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-21-2017 10:32 AM
So long as your date format is the same as the system's date format, you should be able to just add the appropriate time string. Given that the date format is YYYY-MM-DD and the time format is HH:MM:SS, here is the change you can make:
if(requesteddate){
var reqDateTime = requesteddate + ' 17:00:00';
g_form.setValue('stnd_req_date',reqDateTime);
}