-1

I have to update the value of a text field on the Order object using Workflow Rule Field Update based on the time the record was created or last updated.

The datetime stamp should be in the format:

YYMMDDHHmmSS

for example:

171031121052

I have tried using this formula:

RIGHT(LEFT(TEXT( $System.OriginDateTime ),4),2) 
&RIGHT(LEFT(TEXT($System.OriginDateTime),7),2) 
&RIGHT(LEFT(TEXT($System.OriginDateTime),10),2) 
&RIGHT(LEFT(TEXT($System.OriginDateTime),13),2) 
&RIGHT(LEFT(TEXT($System.OriginDateTime),16),2) 
&RIGHT(LEFT(TEXT($System.OriginDateTime),19),2)

but i got 000101000000

in wrong format,

can anyone suggest the answer according to today the record is created or updated according to system time

please suggest this formula also, tried to working

RIGHT(LEFT(TEXT( now() ),4),2) 
&RIGHT(LEFT(TEXT(now()),7),2) 
&RIGHT(LEFT(TEXT(now()),10),2) 
&RIGHT(LEFT(TEXT(now()),13),2) 
&RIGHT(LEFT(TEXT(now()),16),2) 
&RIGHT(LEFT(TEXT(now()),19),2)
  • please anyone guide me for the Answer – SFDC Feb 10 '17 at 6:26
1

As per Salesforce documentation, to get the hour, minute, and second from a Date/Time field as a numerical value, use the following formulas where TZoffset is the difference between the user’s time zone and GMT. For hour in 24–hour format:

So you can use a formula like this. Update the formula as per your need.

TEXT(YEAR(DATEVALUE(NOW()))) 
& 
IF(LEN(TEXT(MONTH(DATEVALUE(NOW()))))=1,'0'&TEXT(MONTH(DATEVALUE(NOW()))),TEXT(MONTH(DATEVALUE(NOW())))) 
& 
IF(LEN(TEXT(DAY(DATEVALUE(NOW()))))=1,'0'&TEXT(DAY(DATEVALUE(NOW()))),TEXT(DAY(DATEVALUE(NOW()))))
& 
IF(
  OR(
    VALUE( MID( TEXT( DATETIMEVALUE(NOW()) - TZoffset ), 12, 2 ) ) = 0,
    VALUE( MID( TEXT( DATETIMEVALUE(NOW()) - TZoffset ), 12, 2 ) ) = 12
  ),
  "12",
  TEXT( VALUE( MID( TEXT( DATETIMEVALUE(NOW()) - TZoffset ), 12, 2 ) ) 
   -
   IF( 
     VALUE( MID( TEXT( DATETIMEVALUE(NOW()) - TZoffset ), 12, 2 ) ) < 12, 
     0, 
     12 
   ) 
  )
)
&
MID( TEXT( DATETIMEVALUE(NOW()) - TZoffset ), 15, 2 )
&
MID( TEXT( DATETIMEVALUE(NOW()) - TZoffset ), 18, 2 )

To calculate the TZoffset refer to this SFSE link.

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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