update date time field with date field

samadam
Kilo Sage

I am trying to update the date time field with date value and it is not working. Tried the following:

var date = current.temp_date;
      var gdt = new GlideDateTime(date);
   
    if (gdt.getValue() != ''){
        gdt.addHours(11);
        gdt.addMinutes(59);
        gs.info("Date Time " + gdt.getDisplayValue());
        current.due_date = gdt.getDisplayValue();
       
        //current.due_date = gdt.getValue();
    }
Tried this but could not get it to work, Tried with and without adding hours and minutes.
1 ACCEPTED SOLUTION

Chaitanya ILCR
Kilo Patron

Hi @samadam ,

try this

var date = current.getValue('temp_date');
var gdt = new GlideDateTime(date + ' 11:59:00');

if (gdt.getValue() != '') {
    // gdt.addHours(11);
    // gdt.addMinutes(59);
    gs.info("Date Time " + gdt.getDisplayValue());
    current.due_date = gdt.getDisplayValue();
}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

View solution in original post

2 REPLIES 2

Chaitanya ILCR
Kilo Patron

Hi @samadam ,

try this

var date = current.getValue('temp_date');
var gdt = new GlideDateTime(date + ' 11:59:00');

if (gdt.getValue() != '') {
    // gdt.addHours(11);
    // gdt.addMinutes(59);
    gs.info("Date Time " + gdt.getDisplayValue());
    current.due_date = gdt.getDisplayValue();
}

 

Please mark my answer as helpful/correct if it resolves your query.

Regards,
Chaitanya

 

samadam
Kilo Sage

Thank you, that worked.