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 - Part6
  5. eScript Best Practices - Part7

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.

11 Responses to “How To find Time Difference in Seconds using eScript”

Post A Comment

Recent Posts 

Recent Comments:

  • Gloria: Thank you for sharing your knowledge!
  • Sridhar: Hi Satya, Please share your documents using “Participate” link on the right hand side. Many thanks...
  • satya vardhan: hi ramya this is vardhan i am in obiee developer i am not undrstanding ur query can u repeat once again...
  • satya vardhan: hi sri obiee this is reporting tool if u want more details send me ur mailid. i can forword some documents...
  • Ramya: Hi, Can u pls tell me how to get the difference between two date fields by ignoring weekends (i.e satday, sunday if...