We're reclaiming inactive PDIs to keep them available for active builders. Learn what's changing, who's affected, and how to protect your work. Read More

update date time field with date field

samadam
Mega 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
Giga 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
Giga 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
Mega Sage

Thank you, that worked.