You need to sign in to do that
Don't have an account?
SunnyShiny
Caclulate a field everyday
Hello,
How can I do to calculate a field everyday with a calcul based on the today date?
Thanks
function readOnly(count){ }
You need to sign in to do that
Don't have an account?
Hello,
How can I do to calculate a field everyday with a calcul based on the today date?
Thanks
One thing is left.
Yes this also will give updated values in reports
All Answers
where you want to do this i mean in formula field. trigger or class
if formula field.
IF(DATE.NOW() > CreatedDate, Sum(a,b), 0);
I just said SUM for Understanding get right one over there.
If Trigger or Apex Class.
Date today = Date.Today();
Date cDate = Date.Value(CreatedDate);
Integer a,b,c;
IF(today.daysBetween(cDate) > 0){
c= a+b;
}
If this answers your question make this as a solution.
Ok for a formula field but will that be updated automatically everday?
There is already one attribute given in formula field " TODAY() " so you can use it. now please what exactly you need to show number of days between created Date and today or any thing else ?
Note: formula field always gets calculatted whenever it gets read/accessed by user so Dont worry about it.
yes difference between created date and today.
Thanks for your answer. Is it also updated when a user consult a report ?
A formula field is not a stored value in the database. When ever a record is viewd or queried by any means the formula field is evaluated at run-time. So if you have a report that is auto emailed daily and the formula uses TODAY() then the value of TODAY() will always equate to the date when the report runs. It should give you what you want.
Hi,
to calculate you should use below formula fiels( Text Type):
TEXT(FLOOR((NOW()-CreatedDate)))
Please let me know in case of any other issue
One thing is left.
Yes this also will give updated values in reports