Note this topic is regarding the newly introduced time fields in Zoho Creator and NOT the Date-Time Fields.
1. Morning_Start_Time
2. Morning_End_Time
In order to calculate hours between them, add the following script on user input of both the fields.
if(Morning_Start_Time != null && Morning_End_Time != null)
{
mst = input.Morning_Start_Time.getHour()
* 3600 + input.Morning_Start_Time.getMinutes()
* 60 + input.Morning_Start_Time.getSeconds();
met = input.Morning_End_Time.getHour()
* 3600 + input.Morning_End_Time.getMinutes()
* 60 + input.Morning_End_Time.getSeconds();
if(mst > met)
{
alert "Morning Start time should be Smaller then Morning End Time";
input.Morning_End_Time = "";
}
else
{
morning_hours = ((met - mst) / 3600).round(2);
}
}
Input.Hours = morning_hours;