Announcing the Global SNUG Board of Directors. Learn more here

Help
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
tiagomacul
Mega Sage
Mega Sage

        Exemplo como separar dia, mês e ano de uma data

var Obj = new GlideRecord("u_minha_tabela");

Obj.orderByDesc('sys_created_on');  

Obj.query();

Obj.next();

var gdt = new GlideDateTime(Obj.sys_created_on);

year = gdt.getYearUTC();

month = gdt.getMonthUTC();

day = gdt.getDayOfMonthUTC();

gs.print(year);

gs.print(month);

gs.print(day);

var dia = gs.nowDateTime().substr(0,2);

var mes = gs.nowDateTime().substr(3,2);

var ano = gs.nowDateTime().substr(6,4);

var hora = parseFloat(gs.nowDateTime().substr(11,2));

if (hora < 22) {

    hora = hora + 2;

    if (hora <= 9) {

          hora = "0" + hora.toString();

    }

} else {

    if (hora == 22) {

          hora = "00";

    }

    if (hora == 23) {

          hora = "01";

    }

}

var minuto = parseFloat(gs.nowDateTime().substr(14,2));

if (minuto != 0) {

    minuto = minuto;

    if (minuto <= 9) {

          minuto = "0" + minuto.toString();

    }

}

var segundo = gs.nowDateTime().substr(17,2);

var novaData = ano + '-' + mes + '-' + dia + ' ' + hora + ':' + minuto + ':' + segundo;

var query = "sys_created_on<" + novaData;

gs.print(gs.nowDateTime());

gs.print(ano + mes + dia + ' ' + hora + minuto + segundo);

By: Ederson Ferreira dos Santos

GlideRecord