4

I am trying to create a formula in my custom report to show number of days between CUSTOM_FIELD (datetime field) and NOW().

How can I do this?

5

Create a formula field of type number on your object that contains

NOW() - Custom_Field__c

And you will get this value

example

then include it in your report

1

If you are only interested in the number of days and not the number of hours, you could also use
TODAY() - DATEVALUE(Custom_Field__c)

TODAY() and NOW()
The TODAY() function returns the current day, month, and year as a Date data type. This function is useful for formulas where you are concerned with how many days have passed since a previous date, the date of a certain number of days in the future, or if you just want to display the current date. The NOW() function returns the Date/Time value of the current moment. It’s useful when you are concerned with specific times of day as well as the date. For details on how to convert between Date values and Date/Time values, see Converting Between Date/Time and Date.

Converting Between Date/Time and Date
Date and Date/Time aren’t interchangeable data types, so when you want to perform operations between Date and Date/Time values, you need to convert the values so they are both the same type. Some functions (such as YEAR(), MONTH(), and DAY()) also only work on Date values, so Date/Time values must be converted first. Use the DATEVALUE( date/time ) function to return the Date value of a Date/Time. For example, to get the year from a Date/Time, use YEAR( DATEVALUE( date/time ) ) ).

https://help.salesforce.com/HTViewHelpDoc?id=formula_using_date_datetime.htm&language=en_US

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.