Siebel Tools >  Date and String Functions in eScript

Date and String Functions in eScript

 

Convert Date to StringConvert Date to String


function DateToString(inputDate)

{
var stringMonth = ToString(inputDate.getMonth() + 1);

var stringDay = ToString(inputDate.getDate());

var stringHours = ToString(inputDate.getHours());

var stringMinutes = ToString(inputDate.getMinutes());

var stringSeconds = ToString(inputDate.getSeconds());


if (stringMonth.length == 1)

{

stringMonth = "0" + stringMonth;

if (stringDay.length == 1)

{

stringDay = "0" + stringDay;

}

 if (stringHours.length == 1)

{

stringHours = "0" + stringHours;

if (stringMinutes.length == 1)

{

stringMinutes = "0" + stringMinutes;

if (stringSeconds.length == 1)

{

stringSeconds = "0" + stringSeconds;


   return (stringMonth +"/"+  stringDay +"/" + inputDate.getFullYear() +" "+stringHours+":"+stringMinutes+":"+stringSeconds);

}


Return Day of the Week 
function GetWeekday(Inputs, Outputs)

{

var date:Date = new Date(Inputs.GetProperty("Date"));

var weekDay:Object =

{

0:"Sunday", 1:"Monday", 2:"Tuesday",3:"Wednesday",4:"Thursday",5:"Friday", 6: "Saturday"

};

Outputs.SetProperty("Weekday", weekDay[date.getDay()]);

}


Convert String to Date


function StringToDate (inputDate)

{

var stringDateTime = inputDate.split(" ");

var stringDate = stringDateTime[0];

var stringSplitDate = stringDate.split("/");


var stringDay = ToNumber(stringSplitDate[1]);

var stringMonth = ToNumber(stringSplitDate[0]);

var stringYear = ToNumber(stringSplitDate[2]);


if (stringDateTime.length == 1)

return (new Date(stringYear, stringMonth-1, stringDay))

else { var stringTime = stringDateTime[1];

var lSplitTime = stringTime.split(".");

if (lSplitTime[0]=="00" && lSplitTime[1]=="00" && lSplitTime[2]=="00")

return (new Date(stringYear, stringMonth-1, stringDay))

else

{

var stringHours = ToNumber(lSplitTime[0]);

var stringMinutes = ToNumber(lSplitTime[1]);

var stringSeconds = ToNumber(lSplitTime[2]);

return (new Date(stringYear,stringMonth-1,stringDay,stringHours,stringMinutes,stringSeconds));


}

}


}