Sunday, December 23, 2012

How to get the Date difference in Days, Hours, Minutes, Seconds


A one liner solution for requirement to find out the date difference between two different dates in eScript:

function Service_PreInvokeMethod (MethodName, Inputs, Outputs)
var Date1 = new Date("12/22/2012");
var Date2 = new Date("12/23/2012");

TheApplication().RaiseErrorText(
"Date1 =" + Date1 + 
"\n Date2 = " + Date2 + 
"\n Date Difference in Days = " + (Date2.getTime() - Date1.getTime())/(1000*60*60*24) + 
"\n Date Difference in Hours = " + (Date2.getTime() - Date1.getTime())/(1000*60*60) + 
"\n Date Difference in Minutes = " + (Date2.getTime() - Date1.getTime())/(1000*60) + 
"\n Date Difference in Seconds = " + (Date2.getTime() - Date1.getTime())/(1000));

            return (CancelOperation);
}

Here below is the output:



4 comments:

  1. Hi Gaurav,

    Sorry to post here, but i have one requirement in my project where on click of a button i have to export the records in the list applet in a excel file and place the excel file on to server which is a unix box. I know siebel provide vanilla export functionality but in my case i have to export records in a specified format like if SR no present in list applet is 2231 we need to append it by 2BT,and amount needs to appended by some zeroes , padding of zeroes to be done to number fields etc.. so such kind of formatting needs to be done to the data present in the list applet and after that file (excel) should be automatically placed on the server path which we will specify.Hope you understood my requirement. I have never worked on such kind of requirement.I would be thankful if you could help me on to this.Thanks in anticipation..

    ReplyDelete
  2. Hi Navneet,

    You can get help from following post for getting the export out in excel file:

    http://siebelmantra.blogspot.com/2009/04/scheduling-automatic-export-in-siebel.html

    And regarding the formatting needs to be done as per your requirement and appending some zeroes etc, you can use calculated fields.

    Cheers
    Gaurav

    ReplyDelete
    Replies
    1. Hi Gaurav,

      Thanks for the reply, sorry to bother you again,just wanted to check one thing from you.Actually currently we are using siebel 8.0.0.5 for our client but client has asked to upgrade siebel version to 8.0.0.12 for CTI stability, we are using avaya CTI integration. As i have not worked in this area could you please let me know what exactly will need to be done and the challenges involved.Thanks in anticipation :)

      Delete
    2. HI Navneet,

      I haven't worked on CTI yet, it is a new area for me and will definitely want to explore in future :)
      Request you to please post the question under "Forum" section if is it not related to the post :)

      Cheers
      Gaurav

      Delete