Skip to content

Commit 4d92d35

Browse files
authored
Merge pull request #305 from nocodb/docs/dateadd
docs: dateadd
2 parents 520c469 + de464c4 commit 4d92d35

File tree

1 file changed

+16
-7
lines changed

1 file changed

+16
-7
lines changed

content/docs/fields/field-types/formula/date-functions.mdx

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,28 +27,37 @@ This function compares two dates and returns the difference in the specified uni
2727
---
2828

2929
## DATEADD
30+
3031
The DATEADD function adds a specified value to a date or datetime.
3132

3233
#### Syntax
34+
3335
```plaintext
34-
DATEADD(date | datetime, value, ["day" | "week" | "month" | "year"])
36+
DATEADD(date | datetime, value, ["second" | "minute" | "hour" | "day" | "week" | "month" | "year"])
3537
```
3638

3739
#### Sample
40+
3841
```plaintext
39-
DATEADD('2022-03-14', 1, 'day') => 2022-03-15
40-
DATEADD('2022-03-14', 1, 'week') => 2022-03-21
41-
DATEADD('2022-03-14', 1, 'month') => 2022-04-14
42-
DATEADD('2022-03-14', 1, 'year') => 2023-03-14
42+
DATEADD('2022-03-14 10:00:00', 30, 'second') => 2022-03-14 10:00:30
43+
DATEADD('2022-03-14 10:00:00', 15, 'minute') => 2022-03-14 10:15:00
44+
DATEADD('2022-03-14 10:00:00', 2, 'hour') => 2022-03-14 12:00:00
45+
DATEADD('2022-03-14', 1, 'day') => 2022-03-15
46+
DATEADD('2022-03-14', 1, 'week') => 2022-03-21
47+
DATEADD('2022-03-14', 1, 'month') => 2022-04-14
48+
DATEADD('2022-03-14', 1, 'year') => 2023-03-14
4349
```
4450

4551
#### Conditional Example
52+
4653
```plaintext
47-
IF(NOW() < DATEADD(date, 10, 'day'), "true", "false") => If the current date is less than the specified date plus 10 days, it returns true. Otherwise, it returns false.
54+
IF(NOW() < DATEADD(date, 10, 'day'), "true", "false")
55+
=> If the current date is less than the specified date plus 10 days, it returns true. Otherwise, it returns false.
4856
```
4957

5058
#### Remark
51-
This function supports date and datetime fields and can handle negative values.
59+
60+
This function supports date and datetime fields, can handle negative values, and works with units down to seconds.
5261

5362
---
5463

0 commit comments

Comments
 (0)