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
Son Tung MaiSon Tung Mai 

difference between 2 picklist value time fields

hi everyone

i have 2 picklist fields for time values of a course sessions with the format including AM, PM as below
1. start time (i.e. 6:00 AM, 6:15 AM, etc)
2. end time (i.e. 6:00 AM, 6:15 AM, etc)

i want to create a formula field to work out the difference between the values selected for these 2 fields, to display the duration scheduled for a session

for example, if start time = 6:00 AM and end time = 8:00 AM, the session duration will be 2 hours

i have tried different syntax but still going nowhere

the current one im using is ((TEXT(End_Time__c)  -  TEXT(Start_Time__c))*1440)

but it giving me an error " Error: Incorrect parameter type for operator '-'. Expected Number, Date, DateTime, received Text"

can anyone help please?
salesforce mesalesforce me
So 9.30 becomes 540 + 30 = 570

If PM convert to 24 hour equivalent (I.e add 12 to hours) 6.15 = 18 x 60 + 15 = 1095

Then subtract to get the difference and divide by 60

1095-570= 525 / 60 = 8.75
Son Tung MaiSon Tung Mai
not sure if i follow
can you please collaborate?