0

This question already has an answer here:

I have date time field on my object. In another field i need to display only the time value of the field.

Date value field: 7/21/2017 12:12 AM

Desired field output: 12:12 AM.

I tried the below formula:

     RIGHT(TEXT(Datevaluefield__c),8)

It is returning 7:12:00Z, in GMT format. Can some suggest a way to get time value alone from datetime field.

Thanks in advance.

marked as duplicate by martin, Dave Humm, Markus Slabina, Ratan Paul, Santanu Boral Jul 21 '17 at 14:02

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

0

Use this below formula it should work : -

IF( OR( VALUE( MID( TEXT(CreatedDate - TZoffset ), 12, 2 ) ) = 0, VALUE( MID( TEXT(CreatedDate - TZoffset ), 12, 2 ) ) = 12 ), "12", TEXT( VALUE( MID( TEXT( CreatedDate - TZoffset ), 12, 2 ) ) - IF( VALUE( MID( TEXT(CreatedDate - TZoffset ), 12, 2 ) ) < 12, 0, 12 ) ) ) & ":" & MID( TEXT( CreatedDate - TZoffset ), 15, 2 ) & ":" & MID( TEXT( CreatedDate - TZoffset ), 18, 2 ) & " " & IF( VALUE( MID( TEXT( CreatedDate - TZoffset ), 12, 2 ) ) < 12, "AM", "PM" )

where createddate in date time field and Zoffset is the difference between the user’s time zone and GMT. So Please set that value first.

  • I am getting the below error..Field TZoffset does not exist. How can i enable this field? – venky Jul 21 '17 at 7:39
  • TZoffset is the difference between user's time zone ans GMT. – Avijit Das Jul 21 '17 at 7:55
  • What ever the TZoffset i am setting, it is giving the same value..not changing..any idea? – venky Jul 21 '17 at 9:19
0

you can try this

IF(
  OR(
    VALUE( MID( TEXT( ***date/time*** - TZoffset ), 12, 2 ) ) = 0,
    VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) = 12
  ),
  "12",
  TEXT( VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) 
   -
   IF( 
     VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12, 
     0, 
     12 
   ) 
  )
)
& ":" &
MID( TEXT( date/time - TZoffset ), 15, 2 )
& ":" &
MID( TEXT( date/time - TZoffset ), 18, 2 )
& " " &
IF(
  VALUE( MID( TEXT( date/time - TZoffset ), 12, 2 ) ) < 12,
  "AM",
  "PM"
)

Hope it helps! thanks

Not the answer you're looking for? Browse other questions tagged or ask your own question.