Skip to content

Instantly share code, notes, and snippets.

@ReidCarlberg
Last active November 25, 2019 15:53
Show Gist options
  • Save ReidCarlberg/8869492 to your computer and use it in GitHub Desktop.
Save ReidCarlberg/8869492 to your computer and use it in GitHub Desktop.
A formula field for calculating a timeframe.
if (
and (
YEAR(Date_Start__c) == YEAR(TODAY()),
IF(
CEILING( ( Date_Start__c - DATE( YEAR( Date_Start__c ), 1, 1) + 1) / 7) > 52,
52,
CEILING( ( Date_Start__c - DATE( YEAR( Date_Start__c ), 1, 1) + 1) / 7)
) ==
IF(
CEILING( ( TODAY() - DATE( YEAR( TODAY() ), 1, 1) + 1) / 7) > 52,
52,
CEILING( ( TODAY() - DATE( YEAR( TODAY() ), 1, 1) + 1) / 7)
)
),
"1. This Week",
IF (Date_Start__c < TODAY(),
"0. Past",
if (
Date_Start__c - TODAY() < 91,
"2. Next 90 Days",
"3. Future"
)
)
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment