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
qlarionqlarion 

Creating a formula that assigns a number to a day of the year

Does anyone know a way to assign a numeric value to the days left in a year? I need to come up with a formula for Current Fiscal Year Revenue where CFY Revenue = [Days left in Current FY/365] x Order Amount  and I do not know how to get a numeric value for "Days left in Current FY" from Salesforce.

 

Thanks,

Laura

_Prasu__Prasu_

The below given code finds the days remaining in the current year. Its in JavaScript.

 

 

today=new Date()
var endofyear=new Date(today.getFullYear(), 11, 31)
var one_day=1000*60*60*24
//Calculate difference btw the two dates, and convert to days
document.write("<b>"+Math.ceil((endofyear.getTime()-today.getTime())/(one_day))+"</b> days remaining this year!")

today=new Date()var endofyear=new Date(today.getFullYear(), 11, 31)var one_day=1000*60*60*24
//Calculate difference btw the two dates, and convert to daysdocument.write("<b>"+Math.ceil((endofyear.getTime()-today.getTime())/(one_day))+"</b> days remaining this year!")

 

mh218mh218

Laura -

 

If you want to go the standard formula route, this should work:

 

365 - (TODAY() - DATE(YEAR(TODAY()), 1, 1) + 1)