Data Functions
Function Signature
Description
Examples
TODAY()
Returns the current date in logged user's time zone when used with a date field.
Returns 12 AM on the current date (logged in user's time zone) when used with a datetime field.
When this value is assigned to a text type field, the format of the returned value is yyyy-MM-dd.
Target Field: Work Order > Billing TypeRequirement: Leave Billing Type unchanged if Customer Down is checked; else, set it to Paid.
Formula:
$F.IF($F.EQUAL($D.Work_Order.SVMXC__Customer_Down__c,'true'), $D.Work_Order.SVMXC__Billing_Type__c, 'Paid')Target Field: Work Order Scheduled DateRequirement: Set Scheduled Date to today.Formula: $F.TODAY()
NOW()
Returns the datetime in logged-in user's time zone, representing the current moment.
When the returned value is assigned to a text type field, the format of the returned value is yyyy-MM-dd HH:mm:ss, in logged in user's time zone.
Target Field: Work Order > Actual Onsite Response
Requirement: Set Actual Onsite Response to now.
Formula: $F.NOW()
DATE (year,month,day)
Creates a date from year, month and day, where all are numeric values / fields, with year being specified as a 4-digit number.
When the returned value is assigned to a text type field, the format of the returned value is yyyy-MM-dd.
Target Field: Work Order > Next Scheduled Date (custom field)
Requirement: Set Next Scheduled Date to 1st day of the created month in next year.
Formula:
$F.DATE($F.YEAR($D.Work_Order.CreatedDate)+1, $F.MONTH($D.Work_Order.CreatedDate), 1)
DATEVALUE (expression)
Creates a date in the logged in user's time zone, from its datetime or text representation.
When the argument is a string / text field, the expected format is yyyy-MM-dd HH:mm:ss or yyyy-MM-dd in the logged in user's time zone, for date and datetime values respectively.
Target Field: Work Detail (Labor) Start Date (custom field)
Requirement: Set Start Date to the date part of Start Date and Time field.Formula:
$F.DATEVALUE($D.Labor.SVMXC__Start_Date_and_Time__c)
DATETIMEVALUE (expression)
Creates a datetime in the logged in user's time zone, from its date or text representation.
If the argument is a date, 12 AM in the logged in user's time zone is considered as the time to create the datetime value.
When the argument is a string / text field, the expected format is yyyy-MM-dd HH:mm:ss or yyyy-MM-dd in the logged in user's time zone, for date and datetime values respectively.
Target Field: Work Order > Next Scheduled Date Time (custom field)
Requirement: Set Next Scheduled Date Time to 12 AM on the 1st day of the created month in next year.
Formula:
$F.DATETIMEVALUE($F.DATE($F.YEAR($D.Work_Order.CreatedDate)+1, $F.MONTH($D.Work_Order.CreatedDate), 1))
DATEDIFF (date1,date2,option)
Returns the difference between two date or datetime fields in days/weeks/months/years. The value returned will be negative if value2 is greater than value1.unit_of_difference must be INDAYS, INWEEKS, INMONTHS, or INYEARS.
The returned number can be set as the value of a text type field also.
Target Field: Work Order > Initial To Completion Days (custom field)
Requirement: Difference in days from Actual Initial Response to Completed Date Time
Formula:
$F.DATEDIFF($D.Work_Order.SVMXC__Completed_Date_Time__c, $D.Work_Order.SVMXC__Actual_Initial_Response__c, 'INDAYS')
DAY (date or datetime)
Returns the day of the month, a number between 1 and 31, for the date or datetime value argument passed.
The returned number can be set as the value of a text type field also.
Target Field: Work Detail (Labor) > Activity Day (custom field)
Requirement: Set Activity Day to the day of the month of the Start Date and Time field.
Formula:
$F.DAY($D.Labor.SVMXC__Start_Date_and_Time__c)
MONTH (date or datetime)
Returns the month, a number between 1 (January) and 12 (December), for the date or datetime value argument passed.
The returned number can be set as the value of a text type field also.
Target Field: Work Detail (Labor) > Activity Month (custom field)
Requirement: Set Activity Month to the day of the month of the Start Date and Time field.
Formula:$F.MONTH($D.Labor.SVMXC__Start_Date_and_Time__c)$F.Add($F.DAY($D.Labor.SVMXC__Start_Date_and_Time__c),1)
YEAR (date or datetime)
Returns the year of a date, a number between 1900 and 9999, for the date or datetime value argument passed.
The returned number can be set as the value of a text type field also.
Target Field: Work Detail (Labor) > Activity Year (custom field)
Requirement: Set Activity Year to the day of the month of Start Date and Time field.
Formula:
$F.YEAR($D.Labor.SVMXC__Start_Date_and_Time__c)
* 
In SFM formulas, some aspects of behavior of date functions might not be similar to Salesforce date functions. For example, $F.DATE($F.YEAR($D.Work_Order.CDate2__c),$F.MONTH($D.Work_Order.CDate2__c),$F.DAY($D.Work_Order.CDate2__c)+1) might return a null value instead of returning the correct date. This issue occurs because the date function does not increment/decrement the value correctly in the case of the last/first day of the month .
Was this helpful?