Search Blog

Loading...

Date functions in Siebel eScript

If you have worked on any date field then you would be knowing that some of the standard date functions are not available in Siebel escript, like converting date from one format to another, adding number of business days to a particular date, comparing two dates etc.,

Here are some methods built in eScript that perform these operations.



1. AddDays
This function serves the purpose of DateAdd function available in other languages. Basically, when we need to add x days to a date, we can use this function.

function AddDays(myDate,days) 
{
/* Adds the number of Days specified in the input parameter ‘days’ 
 *  to the input parameter mydate and returns the new date
 * @param myDate,days
 * @return new Date
*
 */

    return new Date(myDate.getTime() + days*24*60*60*1000);
}

2. SubtractDays

This function helps in finding a backdated date.

function SubtractDays(myDate,days)
{
/**
 * Will subtract ‘days’ number of 
 * days from the input date and return the new date
 * @param myDate,days 
 * @return date 
 * @modified 
 */
 return new Date(myDate.getTime() - days*24*60*60*1000);
}


3. IsFutureDate
This function is used to find if any date is greater than today.

function IsFutureDate(mydate)
{
/*
 *  Function to check if a date is greater than today
 *  Returns 0 if Current Date is larger
 *  1 if Passed Variable is larger
*/

var istoday = new Date();   
var myM = ToInteger(mydate.getMonth()+1);
var myD = ToInteger(mydate.getDate());
var myY = ToInteger(mydate.getFullYear());
var toM = ToInteger(istoday.getMonth()+1);
var toD = ToInteger(istoday.getDate());
var toY = ToInteger(istoday.getFullYear()); 
if ((myY < toY)||((myY==toY)&&(myM < toM))||((myY==toY)&&(myM==toM)&&(myD < = toD)))
 { 
  return(0);
 }
else 
{ 
  return(1);
}
}

4. CompareDates This function is used to compare two dates and to find if one date is greater than or lesser than the other date.
function CompareDates(dte_from,dte_to)
{
/* Function to compare two dates.. will return 1 if dte_from is greater than dte_to else will return 0 */

var myM = ToInteger(dte_from.getMonth()+1);
var myD = ToInteger(dte_from.getDate());
var myY = ToInteger(dte_from.getFullYear());
var toM = ToInteger(dte_to.getMonth()+1);
var toD = ToInteger(dte_to.getDate());
var toY = ToInteger(dte_to.getFullYear()); 
if ((myY < toY)||((myY==toY)&&(myM < toM))||((myY==toY)&&(myM==toM)&&(myD < = toD)))
 { 
  return(0);
 }
else 
{ 
  return(1);
}
}

Other Siebel Blogs

siebel-admin-l @ IT - toolbox

siebel-dev-l @ IT - toolbox