Thursday, July 25, 2013

How to calculate the elapsed time between two Date-Time fields




I have found several functions, scripts and blogs providing different methods to calculate the elapsed time between two date-time fields. However, most of them are hard to understand or involve a higher coding of deluge scripting to obtain the desired result.

Below you will find a solution in 3 lines of code if the Dates belong to the same day

Hr=(input.End_Time.getHour()  -  input.Start_Time.getHour());
Min=(input.End_Time.getMinutes()  /  60  -  input.Start_Time.getMinutes()  /  60);
Elapsed=(Hr  +  Min);

Or 7 lines of code If the Dates vary in Days ...

if(input.Start_Time.getDayOfWeek()  ==  input.End_Time.getDayOfWeek())
{
Hr=(input.End_Time.getHour()  -  input.Start_Time.getHour());
Min=(input.End_Time.getMinutes()  /  60  -  input.Start_Time.getMinutes()  /  60);
Elapsed=(Hr  +  Min);
}
else if(input.Start_Time.getDayOfWeek()  <  input.End_Time.getDayOfWeek())
{
Hr=(input.End_Time.getHour()  -  input.Start_Time.getHour());
Min=(input.End_Time.getMinutes()  /  60  -  input.Start_Time.getMinutes()  /  60);
Day=((input.End_Time.getDayOfYear()  -  input.Start_Time.getDayOfYear())  *  24);
Elapsed=(Day  +  Hr  +  Min);
}

In the following link you will be able to test the script on a live and free application. Elapsed Time

You may locate the following code in the following places: On user input, On Add On Success, or On Edit On Success

Hope it helps....enjoy.
f76bbaee41a7ad6eb60d2a96b6829bce83014907fa936980c3

Friday, July 19, 2013

How to add an image to an HTML View ( page ) in Zoho Creator


If you are already exploring Zoho Creator ability to develop Html Views  ( now known as pages )
you are stepping into a powerful section of your application that will yield great results overtime.

With this in mind you will also need to understand how to incorporate Logos, Images into your pages so the "visual" effect of the application has a more human touch and assist the user to understand what the task in hand is.

Below you will see a sample on how to add a Logo into an HTML View using "Notes" Field. Go to the Form you would like to incorporate the Logo. In this example our "Page" hosts 2 views. View No.1 is Summary Invoice and View No. 2 Product View. Open your Summary Invoice Form and drag the "Add Note" field into the form.

Click Edit on the Note field & look for the Image icon on the top menu bar to upload your image.



Copy & paste the Image URL. 


In order to have a URL you must have uploaded your image to the company server or to a free service such as Flicker or Google  Drive. Click ok and Listo!!!