+ Start a Discussion
Taylor FrissTaylor Friss 

How do I convert Last Transfer Date to a date value?

I am trying to use the Salesforce default Lead field called "Last Transfer Date" as a date field. It is displayed as a date field, but after doing some testing with formulas it appears to secretly be a date time field.

When I use DATEVALUE(LastTransferDate) I get an error of:

Error: Incorrect argument type for function 'DATEVALUE()'.

My end goal is to use TODAY() - LastTransferDate to calculate how many days a Lead has been in a users name. 
Nubes Elite Technologies Pvt. LtdNubes Elite Technologies Pvt. Ltd
Hi Taylor,

CloseDate is already a date value, and does not need to be converted. Also, your formula is effectively an "#Error" value, because you can't divide by zero (X - X = 0). You'll need to adjust your algorithm.
1 - ((CloseDate - TODAY()) / (CloseDate - DATEVALUE( CreatedDate )))

We calculate days between close date and today, and divide by the number of days from the created date. We subtract from 1 to "invert" the value.

Thank You,
www.nubeselite.com
Development | Training | Consulting

Please mark this as solution if your problem is solved.
Ajay K DubediAjay K Dubedi
Hi Taylor,

    You can change your field 'Last Transfer Date' on Lead to date like 
    
        :Datetime Start_Date = Datetime.newInstance(2019, 10, 1, 12, 12, 12);
        :Date Final_date = date.newInstance(Start_Date.Year(), Start_Date.month(),Start_Date.day());   <--- You can use this to Typecast datetime to date
        
    In your case just replace variable 'Start_Date' with field 'Last Transfer Date'
    Then you can calculate difference between 'Today's date' and 'Final_date'
        
        :integer date_difference = Final_date.daysBetween(date.today());

I hope you find the above solution helpful. If it does, please mark as Best Answer to help others too.

Thanks and Regards,
Ajay Dubedi
www.ajaydubedi.com