> For the complete documentation index, see [llms.txt](https://docs.flexikanban.ai/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.flexikanban.ai/references/functions/date-and-time.md).

# Date and Time

## 1. MINUTES

Converts number into minutes value.

{% tabs %}
{% tab title="Usage" %}
`MINUTES(parameter)`&#x20;

Replace `parameter` with the number value to convert it to minutes.
{% endtab %}

{% tab title="Example" %}
`{Opportunity.RFQ_Date__c} + MINUTES(30)` will add *30* minutes to *RFQ\_Date\_\_c* value.

{% hint style="warning" %}
If do not convert number to minutes, error will occur.
{% endhint %}
{% endtab %}
{% endtabs %}

## 2. HOURS

Converts number into hours value.

{% tabs %}
{% tab title="Usage" %}
`HOURS(parameter)`&#x20;

Replace `parameter` with the number value to convert it to hours.
{% endtab %}

{% tab title="Example" %}
`{Opportunity.RFQ_Date__c} + HOURS(12)` will add *12* hours to *RFQ\_Date\_\_c* value.

{% hint style="warning" %}
If do not convert number to hours, error will occur.
{% endhint %}
{% endtab %}
{% endtabs %}

## 3. DATE

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

{% tabs %}
{% tab title="Usage" %}
`DATE(year, month, day)`&#x20;

Replace:

`year` with a four-digit year;

`month` with a two-digit month;

`day` with a two-digit day.
{% endtab %}

{% tab title="Example" %}
`DATE(2016, 10, 10)` returns **October 10, 2016** as a date value.
{% endtab %}
{% endtabs %}

## 4. DATETIME

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

{% tabs %}
{% tab title="Usage" %}
`DATETIME(year, month, day, hours, minutes, seconds)`&#x20;

Replace parameters with integer values of year, month, day, hours, minutes and seconds.
{% endtab %}

{% tab title="Example" %}
`DATETIME(2005, 1, 2, 20, 30, 0)` returns **January 2, 2005, 8:30 PM** as a datetime value.
{% endtab %}
{% endtabs %}

## 5. DATETIMEGMT

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

{% tabs %}
{% tab title="Usage" %}
`DATETIMEGMT(year, month, day, hours, minutes, seconds)`&#x20;

Replace parameters with integer values of year, month, day, hours, minutes and seconds.
{% endtab %}

{% tab title="Example" %}
`DATETIMEGMT(2005, 1, 2, 20, 30, 0)` returns **January 2, 2005, 8:30 PM GMT** as a datetime value.
{% endtab %}
{% endtabs %}

## 6. DATEVALUE

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

{% tabs %}
{% tab title="Usage" %}
`DATEVALUE(datetime_or_string)`&#x20;

Replace `datetime_or_string` with a date, datetime or text value.
{% endtab %}

{% tab title="Example" %}
`DATEVALUE('11/15/2015')` returns **November 15, 2015** as a date value.
{% endtab %}
{% endtabs %}

## 7. DATETIMEVALUE

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

{% tabs %}
{% tab title="Usage" %}
`DATETIMEVALUE(date_or_string)`&#x20;

Replace `date_or_string` with a date, datetime or text value.
{% endtab %}

{% tab title="Example" %}
`DATETIMEVALUE('2005-11-15 17:00:00')` returns **November 15, 2005 5:00 PM** as a datetime value.
{% endtab %}
{% endtabs %}

## 8. DATETIMEVALUEGMT

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

{% tabs %}
{% tab title="Usage" %}
`DATETIMEVALUEGMT(datetime_or_string)`&#x20;

Replace `datetime_or_string` with a date/datetime or text value.
{% endtab %}

{% tab title="Example" %}
`DATETIMEVALUEGMT('2015-11-15 17:00:00')` returns **November 15, 2005 5:00 PM** as a datetime value in GMT time zone.&#x20;
{% endtab %}
{% endtabs %}

## 9. DATETIMETOGMT

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

{% tabs %}
{% tab title="Usage" %}
`DATETIMETOGMT(datetime_object)`&#x20;

Replace `datetime_object` with a datetime value in context user local time zone.
{% endtab %}

{% tab title="Example" %}
Let current user local datetime value is **6/9/2015 10:09:14 PST**.

`DATETIMETOGMT({$System.DateTime})` returns **6/9/2015 17:09:14 GMT** as a datetime value.
{% endtab %}
{% endtabs %}

## 10. ADDDAYS

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

{% tabs %}
{% tab title="Usage" %}
`ADDDAYS(date/datetime, number_of_days, boolean_consider_weekends)`&#x20;

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.
{% endtab %}

{% tab title="Example" %}
`ADDDAYS(DATE(2019, 02, 12), 2, false)` will return **2019-02-14 00:00:00**.
{% endtab %}
{% endtabs %}

## 11. ADDMONTHS

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

{% tabs %}
{% tab title="Usage" %}
`ADDMONTHS(date/datetime, number_of_months)`&#x20;

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.
{% endtab %}

{% tab title="Example" %}
`ADDMONTHS(DATE(2019, 02, 12), 5)` will return **2019-07-12 00:00:00**.
{% endtab %}
{% endtabs %}

## 12. ADDYEARS

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

{% tabs %}
{% tab title="Usage" %}
`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.
{% endtab %}

{% tab title="Example" %}
`ADDYEARS(DATE(2019, 02, 12), 5)` will return **2024-02-12 00:00:00**.
{% endtab %}
{% endtabs %}

## 13. ADDINTERVAL

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

{% hint style="info" %}
To access business hours records navigate to Setup > Company Profile > Business Hours.
{% endhint %}

{% tabs %}
{% tab title="Usage" %}
`ADDINTERVAL(datetime, interval_string, business_hours_id_optional)`&#x20;

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.

{% hint style="warning" %}
Note: a `business_hours_id_optional` parameter is optional.

If pass an empty string or *null*, interval will be added using 24-hours day, 7-days week, 365-days year.
{% endhint %}
{% endtab %}

{% tab title="Example" %}
Let current system datetime value is **Tuesday, 04/01, 8 AM** and business hours are set to **8 AM to 11 AM, Monday to Friday**.

`FORMAT(ADDINTERVAL({$System.DateTime}, '5h 30m', 'id_of_business_hours_record'))` will return **Wednesday, 04/02, 10:30 AM** value.
{% endtab %}
{% endtabs %}

## 14. SUBTRACTINTERVAL

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

{% hint style="info" %}
To access business hours records navigate to Setup > Company Profile > Business Hours.
{% endhint %}

{% tabs %}
{% tab title="Usage" %}
`SUBTRACTINTERVAL(datetime, interval_string, business_hours_id_optional)`&#x20;

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.

{% hint style="warning" %}
Note: a `business_hours_id_optional` parameter is optional.

If pass an empty string or *null*, interval will be subtracted using 24-hours day, 7-days week, 365-days year.
{% endhint %}
{% endtab %}

{% tab title="Example" %}
`FORMAT(SUBSTRACTINTERVAL(DATETIME(2019, 03, 12, 11, 0, 0), '3h 30m'))` will return **3/12/2019 7:30 AM**.
{% endtab %}
{% endtabs %}

## 15. NORMALIZEDATE

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

{% hint style="info" %}
To access business hours records navigate to Setup > Company Profile > Business Hours.
{% endhint %}

{% tabs %}
{% tab title="Usage" %}
`NORMALIZEDATE(date/datetime, business_hours_id_optional)`&#x20;

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.

{% hint style="warning" %}
Note: a `business_hours_id_optional` parameter is optional.

If pass an empty string or *null*, default business hours setting for the organization will be used to calculate date or datetime.
{% endhint %}
{% endtab %}

{% tab title="Example" %}
Let current system datetime value is **Saturday, 03/16, 2 PM** and business hours are set to **8 AM to 11 AM, Monday to Friday**.

`NORMALIZEDATE({$System.DateTime}, id_of_business_hours_record)` will return a datetime value for **Monday, 3/18 8:00 AM**.
{% endtab %}
{% endtabs %}

## 16. STARTOFDAY

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

{% hint style="info" %}
To access business hours records navigate to Setup > Company Profile > Business Hours.
{% endhint %}

{% tabs %}
{% tab title="Usage" %}
`STARTOFDAY(date/datetime, business_hours_id_optional)`

Replace:&#x20;

`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.

{% hint style="warning" %}
Note: a `business_hours_id_optional` parameter is optional.

If pass an empty string or *null*, default business hours setting for the organization will be used to calculate date or datetime.
{% endhint %}
{% endtab %}

{% tab title="Example" %}
Let current system datetime value is **Wednesday, 03/13, 2 PM** and business hours are set to **8 AM to 11 AM, Monday to Friday**.

`STARTOFDAY({$System.DateTime}, id_of_business_hours_record)` will return datetime value for **Wednesday, 3/13 8:00 AM**.
{% endtab %}
{% endtabs %}

## 17. ENDOFDAY

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

{% hint style="info" %}
To access business hours records navigate to Setup > Company Profile > Business Hours.
{% endhint %}

{% tabs %}
{% tab title="Usage" %}
`ENDOFDAY(date/datetime, business_hours_id_optional)`

Replace:&#x20;

`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.

{% hint style="warning" %}
Note: a `business_hours_id_optional` parameter is optional.\
If pass an empty string or *null*, default business hours setting for the organization will be used to calculate date or datetime.
{% endhint %}
{% endtab %}

{% tab title="Example" %}
Let current system datetime value is **Wednesday, 03/13, 2 PM** and business hours are set to **8 AM to 11 AM, Monday to Friday**.

`ENDOFDAY({$System.DateTime}, id_of_business_hours_record)` will return datetime value for **Wednesday, 3/13, 11AM**.
{% endtab %}
{% endtabs %}

## 18. FORMAT

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

{% tabs %}
{% tab title="Usage" %}
`FORMAT(date/datetime, format_string_optional)`&#x20;

Replace:&#x20;

`date/datetime` with the original date or datetime value;

optional parameter `format_string_optional` with the valid format expression.

{% hint style="info" %}
Check supported formats here: <http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html>).
{% endhint %}
{% endtab %}

{% tab title="Example 1" %}
`FORMAT(DATE(2019, 02, 12))` will return **2/12/2019**.
{% endtab %}

{% tab title="Example 2" %}
`FORMAT(DATETIME(2019, 02, 12, 11, 23, 0))` will return **2/12/2019 11:23 AM**
{% endtab %}

{% tab title="Example 3" %}
`FORMAT(DATETIME(2019, 02, 12, 11, 23, 0), 'h:mm a')` **will return 11:23 AM**.
{% endtab %}
{% endtabs %}

## 19. FORMATGMT

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

{% tabs %}
{% tab title="Usage" %}
`FORMATGMT(date/datetime, format_string_optional)`&#x20;

Replace:&#x20;

`date/datetime` with the original date or datetime value;

optional parameter `format_string_optional` with the valid format expression.

{% hint style="info" %}
Check supported formats here: <http://docs.oracle.com/javase/7/docs/api/java/text/SimpleDateFormat.html>).
{% endhint %}
{% endtab %}

{% tab title="Example" %}
Let organization time zone is **Eastern Standard Time**.

`FORMATGMT(DATETIME(2019, 03, 12, 11, 23, 0))` will return **3/12/2019 3:23 PM**.
{% endtab %}
{% endtabs %}

## 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.

{% tabs %}
{% tab title="Usage" %}
`STARTOFWEEK(date/dateTime)`&#x20;

Replace `date/dateTime` parameter with the date or datetime value which start date of the week is to be determined.
{% endtab %}

{% tab title="Example" %}
`STARTOFWEEK({Opportunity.createdDate})` will return start of the week date for the value of createdDate in GMT timezone.

Let current system datetime value is **Wednesday, 03/13, 2 PM**.

`STARTOFWEEK({$System.DateTime})` will return datetime value for **Monday, 3/11, 2 PM**.
{% endtab %}
{% endtabs %}

## 21. DAYSBETWEEN

Returns number of days between two date or datetime values.

{% tabs %}
{% tab title="Usage" %}
`DAYSBETWEEN(date/datetime, date/datetime, ignoreWeekends)`&#x20;

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.
{% endtab %}

{% tab title="Example" %}
Let `createdDate` equals **2001-07-04** and `closedDate` equals **2001-07-10**

`DAYSBETWEEN({Opportunity.createdDate}, {Opportunity.closedDate}, false)` will return **5**.
{% endtab %}
{% endtabs %}

## 22. DATEDIFF

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

{% hint style="info" %}
To access business hours records navigate to Setup > Company Profile > Business Hours.
{% endhint %}

{% tabs %}
{% tab title="Usage" %}
`DATEDIFF(date/datetime, date/datetime, business_hours_id_optional, result_type_optional, hours_in_day_optional)`&#x20;

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);

{% hint style="info" %}
Duration format looks like this:  **1d 7h 45m**.
{% endhint %}

`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.

{% hint style="warning" %}
Notes:

* A `business_hours_id_optional` parameter is optional.\
  If omit this parameter or pass *null*, function will calculate result using 24-hours day, 7-days week, 365-days year.
* Function with '*Hours*' result type will return full number of hours rounded down. This can be useful to avoid lates in calculated schedules, etc.
* If `hours_in_day_optional` is used, `business_hours_id_optional` should be set to *null* (optional parameters can be omitted only if they are last, otherwise they should be set to *null*).
  {% endhint %}
  {% endtab %}

{% tab title="Example 1" %}
Let `createdDate` = **2001-07-0**4 and `closedDate` = **2001-07-05**&#x20;

`DATEDIFF({Opportunity.createdDate}, {Opportunity.closedDate})` returns **1440** (minutes).
{% endtab %}

{% tab title="Example 2" %}
Let  `createdDate` = **2020-06-29** and `closedDate` = **2020-07-01T03:30:05Z**, and business hours are set as **8 hours per day from Monday to Friday**.

`DATEDIFF({Opportunity.createdDate}, {Opportunity.closedDate}, business_hours_id)` returns **960** (minutes).
{% endtab %}

{% tab title="Example 3" %}
Let  `createdDate` = **2020-06-29** and `closedDate` = **2020-07-01T03:30:05Z**.

`DATEDIFF({Opportunity.createdDate}, {Opportunity.closedDate}, null, DURATION)` will return **44h 30m**.
{% endtab %}

{% tab title="Example 4" %}
Let  `createdDate` = **2020-06-29** and `closedDate` = **2020-07-01T03:30:05Z**.

`DATEDIFF({Opportunity.createdDate}, {Opportunity.closedDate}, null, Hours)` will return **44** (integer number of hours).
{% endtab %}

{% tab title="Example 5" %}
Let  `createdDate` = **2001-07-04** and `closedDate` = **2001-07-05**.

`DATEDIFF({Opportunity.createdDate}, {Opportunity.closedDate}, false, 'Duration', 8)` returns **3d**.
{% endtab %}
{% endtabs %}

## 23. YEAR&#x20;

Returns the year component of a date or datetime value.

{% tabs %}
{% tab title="Usage" %}
`YEAR(parameter)`&#x20;

Replace `parameter` with the date/datetime value.
{% endtab %}

{% tab title="Example" %}
Let `RFQ_Date__c` = **2020-07-01T03:30:05Z**.&#x20;

`YEAR({Opportunity.RFQ_Date__c})` returns **2020** (integer representing year component of `RFQ_Date__c` field value).
{% endtab %}
{% endtabs %}

## 24. MONTH

Returns the month component of a date or datetime value.

{% tabs %}
{% tab title="Usage" %}
`MONTH(parameter)`&#x20;

Replace `parameter` with the date/datetime value.
{% endtab %}

{% tab title="Example" %}
Let `RFQ_Date__c` = **2020-07-01T03:30:05Z**.&#x20;

`MONTH({Opportunity.RFQ_Date__c})` returns **7** (integer representing month component of `RFQ_Date__c` field value).
{% endtab %}
{% endtabs %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter, and the optional `goal` query parameter:

```
GET https://docs.flexikanban.ai/references/functions/date-and-time.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
