You need to sign in to do that
Don't have an account?

calculate time in minutes between last modified date
Hello,
How can i calculate time between last modified date and present modified date and get the time in minutes.
where can i store t, in number field or text field.
thank for suggestion
How can i calculate time between last modified date and present modified date and get the time in minutes.
where can i store t, in number field or text field.
thank for suggestion
Try the following code:
Date d1 = Date.newInstance(1990, 1, 1);
Date d2 = Date.newInstance(2008, 1, 30);
Integer numberofDays = d1.daysBetween(d2);
Integer timeinminutes= (numberofDays)*24*60;
System.debug('difference between two dates'+timeinminutes);
This will result output in minutes.
As per your query you must follow:
Integer timeinmin=(lastmodifieddate - presentmodifieddate)*24*60;
Store the diffrence using Number data type.
Mark it as best answer if this explanation was helpful.
Thanks.
Ajay Dubedi
All Answers
You can store minutes in Number field type.
Present Modified date means you are updating the record today so you can get the current time by using this --- system.now()
Time_Difference__c = (LastModifiedDate - system.now()) * 24 * 60
Mark this answer as solved if its help you.
Try the following code:
Date d1 = Date.newInstance(1990, 1, 1);
Date d2 = Date.newInstance(2008, 1, 30);
Integer numberofDays = d1.daysBetween(d2);
Integer timeinminutes= (numberofDays)*24*60;
System.debug('difference between two dates'+timeinminutes);
This will result output in minutes.
As per your query you must follow:
Integer timeinmin=(lastmodifieddate - presentmodifieddate)*24*60;
Store the diffrence using Number data type.
Mark it as best answer if this explanation was helpful.
Thanks.
Ajay Dubedi
As you use an Integer to for the 'daysBetween' this will only ever return the number of minutes between the two dates, to the nearest day - it won't give you the actual number of minutes (to the nearest minute)