Date and Time

1. MINUTES

Converts number into minutes value.

MINUTES(parameter)

Replace parameter with the number value to convert it to minutes.

2. HOURS

Converts number into hours value.

HOURS(parameter)

Replace parameter with the number value to convert it to hours.

3. DATE

Returns a date value from year, month, and day values you enter.

DATE(year, month, day)

Replace:

year with a four-digit year;

month with a two-digit month;

day with a two-digit day.

4. DATETIME

Returns a date value from year, month, day, hours, minutes and seconds values in the local time zone of the current user.

DATETIME(year, month, day, hours, minutes, seconds)

Replace parameters with integer values of year, month, day, hours, minutes and seconds.

5. DATETIMEGMT

Returns a date value from year, month, day, hours, minutes, seconds in GMT datetime value.

DATETIMEGMT(year, month, day, hours, minutes, seconds)

Replace parameters with integer values of year, month, day, hours, minutes and seconds.

6. DATEVALUE

Returns a date value for a date, datetime or text expression in the local time zone of the current user.

DATEVALUE(datetime_or_string)

Replace datetime_or_string with a date, datetime or text value.

7. DATETIMEVALUE

Returns a datetime value for a date, datetime or text expression in the local time zone of the current user.

DATETIMEVALUE(date_or_string)

Replace date_or_string with a date, datetime or text value.

8. DATETIMEVALUEGMT

Returns a date value for a date, datetime or text expression in the GMT time zone.

DATETIMEVALUEGMT(datetime_or_string)

Replace datetime_or_string with a date/datetime or text value.

9. DATETIMETOGMT

Converts datetime value from the local time zone of a context user to the Greenwich Mean Time value with datetime type.

DATETIMETOGMT(datetime_object)

Replace datetime_object with a datetime value in context user local time zone.

10. ADDDAYS

Returns a new date or datetime value that adds the specified number of days to the value of this instance.

ADDDAYS(date/datetime, number_of_days, boolean_consider_weekends)

Replace:

date/datetime with the date or datetime you want to add days to;

number_of_days with integer number of days that needs to be added to original value;

boolean_consider_weekends with true if calculation should exclude Saturday and Sunday, or false if it should not.

11. ADDMONTHS

Adds the given number of months to the date or datetime value.

ADDMONTHS(date/datetime, number_of_months)

Replace:

date/datetime with the date or datetime you want to add months to;

number_of_months with the integer number of months that needs to be added to original value.

12. ADDYEARS

Adds the given number of years to the date or datetime value.

ADDYEARS(date/datetime, number_of_years)

Replace:

date/datetime with the date or datetime you want to add years to;

number_of_years with the integer number of years that needs to be added to original value.

13. ADDINTERVAL

Adds time interval to the datetime based on the business hours for the current Salesforce organization.

To access business hours records navigate to Setup > Company Profile > Business Hours.

ADDINTERVAL(datetime, interval_string, business_hours_id_optional)

Replace:

datetime parameter with a datetime value;

interval_sting with time interval in the '1d 1h 1m' format ;

business_hours_id_optional with an ID of a business hours record used in your organization.

14. SUBTRACTINTERVAL

Subtracts time interval from the datetime based on the business hours for the current Salesforce organization.

To access business hours records navigate to Setup > Company Profile > Business Hours.

SUBTRACTINTERVAL(datetime, interval_string, business_hours_id_optional)

Replace:

datetime parameter with a datetime value;

interval_sting with time interval in the '1d 1h 1m' format;

business_hours_id_optional with an ID of a business hours record used in your organization.

15. NORMALIZEDATE

Moves a date or datetime to the closer working day according to business hours.

To access business hours records navigate to Setup > Company Profile > Business Hours.

NORMALIZEDATE(date/datetime, business_hours_id_optional)

Replace:

date/datetime parameter with value you need to normalize;

business_hours_id_optional with an ID of a business hours record used in your organization.

16. STARTOFDAY

Moves a date/datetime to the start of working day according to business hours.

To access business hours records navigate to Setup > Company Profile > Business Hours.

STARTOFDAY(date/datetime, business_hours_id_optional)

Replace:

date/datetime parameter with value you need to calculate;

business_hours_id_optional with an id of a business hours record used in your organization.

17. ENDOFDAY

Moves a date/datetime to the end of working day according to business hours.

To access business hours records navigate to Setup > Company Profile > Business Hours.

ENDOFDAY(date/datetime, business_hours_id_optional)

Replace:

date/datetime parameter with value you need to calculate;

business_hours_id_optional with an id of a business hours record used in your organization.

18. FORMAT

Returns a value containing a date expression formatted according to given parameter.

FORMAT(date/datetime, format_string_optional)

Replace:

date/datetime with the original date or datetime value;

optional parameter format_string_optional with the valid format expression.

19. FORMATGMT

Returns a value containing an expression formatted according to given parameter in GMT time value.

FORMATGMT(date/datetime, format_string_optional)

Replace:

date/datetime with the original date or datetime value;

optional parameter format_string_optional with the valid format expression.

20. STARTOFWEEK

Returns date or datetime representing the first day of week for the date passed to the function in the local time zone of the current user.

STARTOFWEEK(date/dateTime)

Replace date/dateTime parameter with the date or datetime value which start date of the week is to be determined.

21. DAYSBETWEEN

Returns number of days between two date or datetime values.

DAYSBETWEEN(date/datetime, date/datetime, ignoreWeekends)

Replace:

first two parameters with the two date/datetime values;

boolean ignoreWeekends with true if calculation should exclude Saturdays and Sundays, or false if it should not.

22. DATEDIFF

Returns number of minutes, hours and days between date/datetime values.

To access business hours records navigate to Setup > Company Profile > Business Hours.

DATEDIFF(date/datetime, date/datetime, business_hours_id_optional, result_type_optional, hours_in_day_optional)

Replace:

first two parameters with two dates;

business_hours_id_optional optional parameter with an ID of a business hours record used in your organization;

result_type_optional optional parameter with one of the following values: 'Duration', 'Hours', 'Days' (this parameter is case-insensitive);

Duration format looks like this: 1d 7h 45m.

hours_in_day_optional is an optional parameter that can be used when user passes 'Duration' or 'Days' as a result_type_optional - it defines number of hours in a day for function calculation.

23. YEAR

Returns the year component of a date or datetime value.

YEAR(parameter)

Replace parameter with the date/datetime value.

24. MONTH

Returns the month component of a date or datetime value.

MONTH(parameter)

Replace parameter with the date/datetime value.

Last updated