Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
ShowAll Questionssorted byDate Posted
Harsh Dodiya

# Last Modified Date (If Record update after 1minute)

Hello,

Requirement
1. I wants Last modified time of any of record.
2. Whenever new records been created, whenever first time record is updated that modified time should come as custom field.
3. If update has been done with in 1st minute(60seconds) the field should come as blank, if update has been done after 1minute the field should show last modified time.
Best Answer chosen by Harsh Dodiya
mritzi
Create a custom Formula Field (return type DateTime)

Write following code in the Formula Text Editor:
```IF( LastModifiedDate  <>  CreatedDate ,
IF( NOW() >  LastModifiedDate+ 1/(24*60), LastModifiedDate , null ), null
)```

Explanation:
If (Modified DateTime not equal to  Created DateTime){
if(NOW > modified DateTime+1 min ){
return Modified DateTime
}
else{return null
}
return null
}

If this solves your problem, mark this as Best Answer

mritzi
Create a custom Formula Field (return type DateTime)

Write following code in the Formula Text Editor:
```IF( LastModifiedDate  <>  CreatedDate ,
IF( NOW() >  LastModifiedDate+ 1/(24*60), LastModifiedDate , null ), null
)```

Explanation:
If (Modified DateTime not equal to  Created DateTime){
if(NOW > modified DateTime+1 min ){
return Modified DateTime
}
else{return null
}
return null
}

If this solves your problem, mark this as Best Answer
This was selected as the best answer
Harsh Dodiya

Mritzi,

Thank you, I used below one and I got the result.
IF( LastModifiedDate  <>  CreatedDate ,
IF( NOW() >  CreatedDate+ 1/(24*60), LastModifiedDate , null ), null
)

Can we get Time difference in another field. Suppose Record creation done at 11.40am and First update has taken place at 11.45am.Then field should show me 5minutes. Can you please help me with this

mritzi
"First update"
"Field should show me 5minutes"

It involves a lot of effort and i am not sure, if its worth the effort.
Because, we first need to mark "first update" that could well be acheived
but calculating time Difference, that is very difficult (as it could range from 1 second to more than a year)
Harsh Dodiya
Mritzi,

Thank you for updates.
Is there any option we can use this via workflow or formula field, and it takes only first update for record.
If there is second update it will keep showing details about first updates only in particular field ??
mritzi
Trigger:
```trigger setFirstModifiedDate on ObjectName(after update){
// change objectName with actual object name API
// change other field names as per your Org data
if(Trigger.isAfter && Trigger.isUpdate){
for(ObjectName obj:Trigger.New){
if(obj.LastModifiedDate != obj.createdDate){
ObjectName oldObj = trigger.oldMap.get(obj.id);
/* if after update, modified date is different from created date
*  and old modified date and created date were same
*  it means current object date is modified for the first time
*/
if(oldObj.LastModifiedDate==oldObj.createdDate){
firstUpdateField = obj.LastModifiedDate;
}
}
}
}
}```

Harsh Dodiya

Mritzi,

Thank you buddy. But Requirement is only for Workflow & Field update related.

Whenever first update happens after 1minute, it will show last modified time in given field. After that what ever update happens,that field won't be changed.

kasa venkat 14
Hi mritzi,

i have an doubt, at the time of creating the case the created date and lastmodified dates of time is not equal,the seconds are having difference,how can i solve this.

for this i want to create a lastmodified date formula field,but i dont have any idea to write it?