Siebel Tools > Datetime functions and calculations
Siebel DateTime Conversions and escript functions
/* Getting Date and Time in format in MM/DD/YYYY HH:MM:SS */ var sGetInstallDateTime = ((sInstallDate.getMonth() + 1) + “/” + sInstallDate.getDate() + “/” + sInstallDate.getFullYear()+ ” “+ sInstallDate.getHours() + “:” + sInstallDate.getMinutes()+”:” + sInstallDate.getSeconds()); /* Getting Date and Time in format MM/DD/YYYY .*/ var sInstallOnlyDate = ((sInstallDate.getMonth() + 1) + “/” + sInstallDate.getDate() + “/” + sInstallDate.getFullYear()); /*Getting DateTime in Milliseconds */ sInstallDateMilliSec = sInstallDate.getTime(); //Converting date into milliseconds for one day sysDateMilliSec = sysDate.getTime() + 31*24*60*60*1000;//Converting Date to millisec by adding 31 days.
AddDays This function serves the purpose of DateAdd function available in other languages. 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); }
SubtractDays
This function helps in finding a date from the past.
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); }
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); } }
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); } }
|