Skip to content

Commit d8f688e

Browse files
Merge pull request #254757 from mumian/1012-datetimeadd
add remarks to datetimeadd()
2 parents 63ea477 + bc6f19b commit d8f688e

File tree

2 files changed

+32
-2
lines changed

2 files changed

+32
-2
lines changed

articles/azure-resource-manager/bicep/bicep-functions-date.md

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Bicep functions - date
33
description: Describes the functions to use in a Bicep file to work with dates.
44
ms.topic: conceptual
55
ms.custom: devx-track-bicep
6-
ms.date: 06/23/2023
6+
ms.date: 10/12/2023
77
---
88

99
# Date functions for Bicep
@@ -30,6 +30,17 @@ Namespace: [sys](bicep-functions.md#namespaces-for-functions).
3030

3131
The datetime value that results from adding the duration value to the base value.
3232

33+
### Remarks
34+
35+
The dateTimeAdd function takes into account leap years and the number of days in a month when performing date arithmetic. The following example adds one month to January 31:
36+
37+
```bicep
38+
output add1MonthOutput string = dateTimeAdd('2023-01-31 00:00:00Z', 'P1M') //2023-03-02T00:00:00Z
39+
output add1MonthLeapOutput string = dateTimeAdd('2024-01-31 00:00:00Z', 'P1M') //2024-03-01T00:00:00Z
40+
```
41+
42+
In this example, `dateTimeAdd` returns `2023-03-02T00:00:00Z`, not `2023-02-28T00:00:00Z`. If the base is `2024-01-31 00:00:00Z`, it returns `2024-03-01T00:00:00Z` because 2024 is a leap year.
43+
3344
### Examples
3445

3546
The following example shows different ways of adding time values.

articles/azure-resource-manager/templates/template-functions-date.md

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ title: Template functions - date
33
description: Describes the functions to use in an Azure Resource Manager template (ARM template) to work with dates.
44
ms.topic: conceptual
55
ms.custom: devx-track-arm-template
6-
ms.date: 05/22/2023
6+
ms.date: 10/12/2023
77
---
88

99
# Date functions for ARM templates
@@ -33,6 +33,25 @@ In Bicep, use the [dateTimeAdd](../bicep/bicep-functions-date.md#datetimeadd) fu
3333

3434
The datetime value that results from adding the duration value to the base value.
3535

36+
### Remarks
37+
38+
The dateTimeAdd function takes into account leap years and the number of days in a month when performing date arithmetic. The following example adds one month to January 31:
39+
40+
```json
41+
"outputs": {
42+
"add10YearsOutput": {
43+
"type": "string",
44+
"value": "[dateTimeAdd('2023-01-31 00:00:00Z', 'P1M')]" //2023-03-02T00:00:00Z
45+
},
46+
"add1MonthOutput": {
47+
"type": "string",
48+
"value": "[dateTimeAdd('2024-01-31 00:00:00Z', 'P1M')]" //2024-03-01T00:00:00Z
49+
}
50+
}
51+
```
52+
53+
In this example, `dateTimeAdd` returns `2023-03-02T00:00:00Z`, not `2023-02-28T00:00:00Z`. If the base is `2024-01-31 00:00:00Z`, it returns `2024-03-01T00:00:00Z` because 2024 is a leap year.
54+
3655
### Examples
3756

3857
The following example template shows different ways of adding time values.

0 commit comments

Comments
 (0)