function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Amer SkroboAmer Skrobo 

How to format Time data type to choose only minutes

Is there way to format Time data type in inputfield,  so when I choose time it gives me hourd and minutes but I want only minutes.
SandhyaSandhya (Salesforce Developers) 
Hi,

If you are using formaula field then you can use MINUTE function.

In Apex use below code
Time myTime = Time.newInstance(3, 14, 15, 926);
System.assertEquals(14, myTime.minute());
Refer below links for more information.

https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_methods_system_time.htm
 
https://help.salesforce.com/articleView?id=custom_field_time_overview.htm&type=5
 
Please mark it as solved if my reply was helpful, it will make it available
for others as a proper solution.

Best Regards,
​Sandhya

 
Amer SkroboAmer Skrobo
Maybe I didn't explain enough well. On page when I select time I want to be able to choose only minutes not hours and minutes.

Example if you want to be able to set how many time one exam takes place in minutes
SandhyaSandhya (Salesforce Developers) 
Hi,

Salesforce Time field will support only below formats

FORMATEXAMPLE
hh:mm:ss aa10:30:25 AM
hh:mm:ss.SSS a10:30:25.125 AM
HH:mm:ss.SSS14:30:25.125
HH:mm:ss.SSSZ14:30:25.125Z displays as GMT
hh:mm a10:30 AM
hh:mma10:30AM
h a4 PM
ha4PM
H:mm1:23 is 1:23 AM
H14 is 2:00 PM
Hmm123 is 1:23 AM
HHmm1434 is 2:34 PM

So you may need to create custom page.

Best Regards,
Sandhya
Amer SkroboAmer Skrobo
Do you have idea how to code it??
Glyn Anderson (Slalom)Glyn Anderson (Slalom)
Amer,  Why don't you use an Integer field with the number of minutes?  Don't use Time...
Asitha_RajuAsitha_Raju
Hi Amer Skrobo,
Is it ok if you use a formula field to convert the time into minutes. I did it by creating a new formula field called Minutes with the expression:
(HOUR( time__c ) * 60)  + MINUTE( time__c )

Try this out. If it helps in sorting out your issue,please mark it as solved.
Thanks.