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

# Comparing dates elapsed time

I am trying to use the following formula but I am getting a syntax error.  Can someone tell me what I am doing wrong?

if(First_Report_Due_Date__c > 30, "2", if(First_Report_Due_Date__c > 60, "3",  "1"))

i am trying to populate a text field to fill in the number of elapsed months.

thanks,

Mirko

JPClark3

( YEAR(TODAY() ) + MONTH( TODAY() ) )   -  ( YEAR(First_Report_Due_Date__c  ) + MONTH( First_Report_Due_Date__c  ) )

Hello,

I've created a custom text field whose sole purpose is to calculate the number of elapsed month.  I need to use an existing First_Report_Due_Date (date field) and compare against the current date to get elapsed time in month.

thanks,

Mirko

Navatar_DbSup

Hi,

You are getting the error because First_Report_Due_Date__c is a date type field and you compare that value with a number. So firstly you have to convert that into a number and then use <,< these operators. I have taken formula field return type as number and CustomDate__c as date type custom field. Below is the Formula for the same:

Value(if( DAY( CustomDate__c) > 30, "2", if(DAY(CustomDate__c )> 60, "3",  "1")))

Well I want to suggest that you can simply use month function to get the current month from that date type field like this:

MONTH(CustomDate__c)

Did this answer your question? If not, let me know what didn't work, or if so, please mark it solved. ﻿

JPClark3

( YEAR(TODAY() ) + MONTH( TODAY() ) )   -  ( YEAR(First_Report_Due_Date__c  ) + MONTH( First_Report_Due_Date__c  ) )

This was selected as the best answer