function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
sunnydalesunnydale 

Compute Age from 2 dates in a VWF

Is it possible to use the Visual Workflow formula to compute the time between 2 Date variable?  I was hoping something like this might work:

 

FLOOR(({!EngagementStart}-{!DateOfBirth})/365.2425)

 

but the result in a running flow that has reasonable values in both Date variables is null.  The formula is placed in a Screen, and the 2 Date variables appears on the screen page looking just like they should.  But the formula fails for some reason.

Best Answer chosen by Admin (Salesforce Developers) 
RajaramRajaram

If there is a sfsc formula to compute this, you should be able to do it. THough, remember that FLow only supports Date and not Date Time.

I tested your formula with 2 date screen fields and the formula seems to be working fine. 

Here is what I have:

FLOOR(({!End_Date}-{!Start_Date})/365.2425)

 

End Date and Start Date are 2 Date Fields

 

I tested it with variables as well and it does seem to work.

 

You should make sure the values are not null or handle null in the formula. 

 

All Answers

RajaramRajaram

If there is a sfsc formula to compute this, you should be able to do it. THough, remember that FLow only supports Date and not Date Time.

I tested your formula with 2 date screen fields and the formula seems to be working fine. 

Here is what I have:

FLOOR(({!End_Date}-{!Start_Date})/365.2425)

 

End Date and Start Date are 2 Date Fields

 

I tested it with variables as well and it does seem to work.

 

You should make sure the values are not null or handle null in the formula. 

 

This was selected as the best answer
sunnydalesunnydale

Rajaram, thanks very much for the encouragement to just stop and think clearly. 

 

You are absolutely right, date formulae work just swimmingly fine in VWF. 

 

In my case, the problem was a profile security error which caused an unexpected default date value in on of the fields in the formula.  Sorry to have wasted your time on this :-(

RajaramRajaram

Good to know you are fine and no you did not waste any of my time at all. Happy to be of help!