SiebelGuide.com/siebelblogs

Siebel Blogs, News, Events, Tips and Tricks
Filed under How To, Tips&Tricks, eScript, All, Configuration

Handling Date and Time functions is very puzzling in eScript. Lot of developers mess around with the code to reach the result.

In this post I will explain the simplest way to find the time difference between two different times in Seconds using Siebel eScript.

Clib.difftime is the method used to calculate the time difference between two times.

As per bookshelf the usage and example as per bookshelf.

Clib.difftime() Method
Syntax
Clib.difftime(timeInt1, timeInt0)

Parameter Description
timeInt0– An integer time value as returned by the Clib.time() function
timeInt1– An integer time value as returned by the Clib.time() function
Returns
The difference in seconds between timeInt0 and timeInt1.
Example
This example displays the difference in time, in seconds, between two times:
function difftime_Click ()
{
var first = Clib.time();
var second = Clib.time();
TheApplication().RaiseErrorText("Elapsed time is " +
Clib.difftime(second, first) + " seconds.");
}

But often time values are retrieved from the a date column in Siebel database. The value retrieved from cant be used directly and needs some manipulation to fit the format. Below is the snippet of the code used to retrieve date/time from the database and find the difference.

//Get Date value from field
var sDate = oBC.GetFieldValue("Opened Date");
//Assign it to Date Object
var sDate1 = new Date(sDate);
//Convert date object to integer equivalent
var sDate2 = sDate1.toSystem();
//find time difference between current time and date opened in seconds
var sTimeDiff = Clib.difftime(Clib.time(), sDate2);

So use this sample code as reference in your eScript. Hope this helps. Leave a comment.

Related posts(Auto Generated):

  1. eScripting Best Practices - Part5
  2. eScripting Best Practices - Part2
  3. PropertyExists Method in Siebel eScript
  4. eScript Best Practices - Part7
  5. eScript Best Practices - Part6

Posted by Sridhar on Friday, October 24th, 2008


Page copy protected against web site content infringement by Copyscape
You can follow any responses to this entry through the magic of "RSS 2.0" and leave a trackback from your own site.

Post A Comment

Recent Posts 

Recent Comments:

  • Sridhar: LDAP mechanism should be handled by Siebel Server. So I dont know why this would matter. I havent tested with...
  • Nitin: Hi, Nice post, however i think this will not work in the case where we are using any aunthentication methods like...
  • Nitin: Hey, Its a nice post but this cannot work if you are using any authetication method like LDAP or something…or...
  • Sridhar: Check Siebel Book Shelf. Siebel Business Process FrameWork workflow guide->Invoking Workflow processes page...
  • Nitin Kumar Jain: Can I control whether the Workflow invoked by the RTE is Synchronous or Asynchronous call. If yes, how?...