Home > Blog > Time Field Type in Salesforce

Time Field Type in Salesforce

Hi friends, This blog is written with Winter ’18 release, where time field still in Beta, So I am going to explain here about Time data type in Salesforce. Currently, We have the ability to create Time/Date fields, Or just Date fields, but not Time fields. A Time field would be handy for – special event management – time tracking – Project Management. Date: Existing Date (data type) allow users to enter a date or pick a date from calendar dialog box. Date/Time: Existing Date/Time (data type) allow users enter a date and time or pick a date from calendar dialog box. When user click a date in the dialog box that date and current time entered in the Date/Time field. Time: It is allow user to enter a local time for example,”2:40 PM”, ”14:40”, ”2:40 Pm” and ”14:40:50.600”. Some valid time format: 0:00, 2:40, 2:40AM, 2:40Am, 14:40, 1:11:11, 2:22:22:22. Some Invalid time format: 24:00, 25:00, -1:11, Abc. There are 2 types of Time fields in winter ’18 beta:
  • As a Custom field with Data Type = Time
  • As a Formula field with Return type = Time
  1. Custom field with Data Type = Time As of now, the display in Lightning is not great, but much nicer in Classic.
Where : “Z”  = When you convert a Date/Time to text, a “Z” is included at the end to indicate GMT. Users with appropriate permission able to type in the time directly into the page layout. In Classic, you can enter the time in 24 hours format:
  • When you have enter “18” and save, this will save as 6:00 PM
  • When you have enter “18:12” and save, this will save as 6:12 PM
  • When you have enter “7:12” and save, this will save as 7:12 AM
  • When you have enter “7.32” and save, this will save as 7:00 AM
You can also enter the time in 12 hours format with AM/PM (in Classic):
  • When you have enter “12 AM ” and save, this will save as 12:00 AM
  • When you have enter “12:30PM/12:30pM ” and save, this will save as 12:30 PM
  1. Formula Field with return type = Time Sample: MINUTE(Approved_Time__c), HOUR(Approved_Time__c) To calculate hours and minutes between time fields, you cannot just minus or add them directly, Submission_Time__c – Approved_Time__c (Negative Result) will return error “Incorrect parameter type for operator ‘-‘”.
Note :
  • Time fields do not include a date. So, adding 25 hours to a time value is the same as adding one hour. The clock restarts after 24 hours.
  • Lightning Experience, Quick Actions, and the Salesforce mobile web: A time field displays GMT, always (15:33:00.000Z).
  • Salesforce calculation Time formula field value in milliseconds.
  Example 1: How to work with Time datatype in salesforce? Step 1: Create a Custom field. Custom Fields –  Time Beta (Time). When you want to insert a time in different cases like – Result : Case 1: Enter a string in field then it will be generate a error message. Because it is not support a text. Case 2: Enter a “20:40 PM” in field then it will be generate a error message. Because “20:40” is 24 hour zone. Case 3: Enter a “2:45” in field then it will display “2:45 AM”. Case 4: Enter a “22:45” in field then it will display “10:45 PM”. Case 5: Enter a “25:00” in field then it will generate an error message. Because It will refresh after “24:00”. Example 2: How to work with Time data type with formula field in salesforce?       In formula Time return type we can add/subtract millisecond in TimeValue of the another field. But It is not support negative result value after execution of formula field. Step 1: Create a formula field. Custom Fields –  Time Formula Field (Time). Result : If we have enter “17:00” in time field then in formula field add 60,000 millisecond with time field value or if you have Date/Time field by using TimeValue() function. Thank You. References: https://help.salesforce.com  
sales
Enquire Now
X

lets get over a cup of coffee and discuss!