+ Start a Discussion
AudmarAudmar 

Can I make a "Time" field (without date)?

I'm a complete newbie, so please bear with me. :)

 

I would like to have a field for Time on a custom object.  I noticed that there is a "Time" class in Apex, but I haven't seen anything about a "Time" field (only DateTime).  Ideally this field would behave like the Date/DateTime fields, and offer a pop-up for selecting a time value.  But more importantly, it should have built-in validation.

 

Does such a field type exist in Salesforce, or would I need to use a Text field with validation rules, and possibly VisualForce to create the "time selector"?

 

Is there a preferred method or best practice for dealing with Time-only values in Salesforce?

 

Thanks for any advice you can give.

Best Answer chosen by Admin (Salesforce Developers) 
IspitaIspita

Hi,

As far are core data types or field types are concerned we have DateTime and there is no provision at field schema level in salesforce to have a "Time" only field.

But you can create one for your self in fuctionality by using salesforce validation rules and custom code ~ for that the base field type can be text.

 

Hope this answers your query....

All Answers

IspitaIspita

Hi,

As far are core data types or field types are concerned we have DateTime and there is no provision at field schema level in salesforce to have a "Time" only field.

But you can create one for your self in fuctionality by using salesforce validation rules and custom code ~ for that the base field type can be text.

 

Hope this answers your query....

This was selected as the best answer
tbuckettbucket

I had a similar need and just created a picklist with times in it.  it is a "dumb" solution as you cannot use it any calculations, but my users loved it and thought it was perfect.

 

The context in this case was a field called "Preferred Time".  It was for a service call.  If your need is this simple, give it a shot.

AudmarAudmar

Thanks for the info.  I was afraid of that.  It would be nice if we could create "custom field types" and specify both client & server validation along with some client side functionality for the field itself (like adding a javascript time picker).  That way we wouldn't have to use a full VF page to make the functionality available.

Rejith VarmaRejith Varma
Responding to a very old post - sorry 

This is delivered in summer 17 as a pilot - check this out 

https://success.salesforce.com/ideaView?id=08730000000BrUVAA0