diff --git a/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue b/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue index 89279b59c5..8aadae7b7e 100644 --- a/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue +++ b/packages/nc-gui/components/smartsheet/column/FormulaOptions.vue @@ -332,7 +332,7 @@ onMounted(() => {
- + View in Docs diff --git a/packages/noco-docs/docs/070.fields/040.field-types/060.formula/040.date-functions.md b/packages/noco-docs/docs/070.fields/040.field-types/060.formula/040.date-functions.md index 9385ad06e1..2b2ce80388 100644 --- a/packages/noco-docs/docs/070.fields/040.field-types/060.formula/040.date-functions.md +++ b/packages/noco-docs/docs/070.fields/040.field-types/060.formula/040.date-functions.md @@ -22,7 +22,7 @@ DATETIME_DIFF("2022/10/14", "2022/10/15", "seconds") => -86400 ``` #### Remark -This function compares two dates and returns the difference in the specified unit. Positive integers indicate that second date is in the past compared to first, and vice versa for negative values. +This function compares two dates and returns the difference in the specified unit. Positive integers indicate that the second date is in the past compared to the first, and vice versa for negative values. --- @@ -94,6 +94,80 @@ Returns the day of the week as an integer between 0 and 6 (inclusive), with Mond --- +## DATESTR +The DATESTR function converts a date or datetime field into a string in "YYYY-MM-DD" format. + +#### Syntax +```plaintext +DATESTR(date | datetime) +``` + +#### Sample +```plaintext +DATESTR('2022-03-14') => 2022-03-14 +DATESTR('2022-03-14 12:00:00') => 2022-03-14 +``` + +#### Remark +This function converts a date or datetime field into a string in "YYYY-MM-DD" format, ignoring the time part. + +--- + +## DAY +The DAY function returns the day of the month as an integer. + +#### Syntax +```plaintext +DAY(date | datetime) +``` + +#### Sample +```plaintext +DAY('2022-03-14') => 14 +DAY('2022-03-14 12:00:00') => 14 +``` + +#### Remark +This function returns the day of the month as an integer between 1 and 31 (inclusive). + +--- + +## MONTH +The MONTH function returns the month of the year as an integer. + +#### Syntax +```plaintext +MONTH(date | datetime) +``` + +#### Sample +```plaintext +MONTH('2022-03-14') => 3 +MONTH('2022-03-14 12:00:00') => 3 +``` + +#### Remark +This function returns the month of the year as an integer between 1 and 12 (inclusive). + +--- + +## HOUR +The HOUR function returns the hour of the day as an integer. + +#### Syntax +```plaintext +HOUR(datetime) +``` + +#### Sample +```plaintext +HOUR('2022-03-14 12:00:00') => 12 +``` + +#### Remark +This function returns the hour of the day as an integer between 0 and 23 (inclusive). + +--- ## Related Articles - [Numeric and Logical Operators](015.operators.md) diff --git a/packages/noco-docs/docs/070.fields/040.field-types/060.formula/060.generic-functions.md b/packages/noco-docs/docs/070.fields/040.field-types/060.formula/060.generic-functions.md new file mode 100644 index 0000000000..be520a837e --- /dev/null +++ b/packages/noco-docs/docs/070.fields/040.field-types/060.formula/060.generic-functions.md @@ -0,0 +1,24 @@ +--- +title: 'Generic Functions' +description: 'This article explains system functions & miscellaneous functions that can be used in formula fields.' +tags: ['Fields', 'Field types', 'Formula'] +keywords: ['Fields', 'Field types', 'Formula', 'Create formula field', 'System functions', 'Miscellaneous functions'] +--- + +# System Functions + +## RECORD_ID + +The `RECORD_ID` function returns the unique identifier of the record. + +#### Syntax +```plaintext +RECORD_ID() +``` + +#### Sample +```plaintext +RECORD_ID() => 1 +``` + +--- diff --git a/packages/nocodb-sdk/src/lib/formulaHelpers.ts b/packages/nocodb-sdk/src/lib/formulaHelpers.ts index 097d3db4fd..b250531a06 100644 --- a/packages/nocodb-sdk/src/lib/formulaHelpers.ts +++ b/packages/nocodb-sdk/src/lib/formulaHelpers.ts @@ -282,6 +282,8 @@ interface FormulaMeta { export const formulas: Record = { AVG: { + docsUrl: + 'https://docs.nocodb.com/fields/field-types/formula/numeric-functions#avg', validation: { args: { min: 1, @@ -296,10 +298,10 @@ export const formulas: Record = { 'AVG({column1}, {column2}, {column3})', ], returnType: FormulaDataTypes.NUMERIC, - docsUrl: - 'https://docs.nocodb.com/fields/field-types/formula/numeric-functions#avg', }, ADD: { + docsUrl: + 'https://docs.nocodb.com/fields/field-types/formula/numeric-functions#add', validation: { args: { min: 1, @@ -314,8 +316,6 @@ export const formulas: Record = { 'ADD({column1}, {column2}, {column3})', ], returnType: FormulaDataTypes.NUMERIC, - docsUrl: - 'https://docs.nocodb.com/fields/field-types/formula/numeric-functions#add', }, DATEADD: { docsUrl: @@ -376,6 +376,8 @@ export const formulas: Record = { returnType: FormulaDataTypes.DATE, }, DATESTR: { + docsUrl: + 'https://docs.nocodb.com/fields/field-types/formula/date-functions#datestr', validation: { args: { rqd: 1, @@ -387,6 +389,8 @@ export const formulas: Record = { returnType: FormulaDataTypes.STRING, }, DAY: { + docsUrl: + 'https://docs.nocodb.com/fields/field-types/formula/date-functions#day', validation: { args: { rqd: 1, @@ -398,6 +402,8 @@ export const formulas: Record = { returnType: FormulaDataTypes.STRING, }, MONTH: { + docsUrl: + 'https://docs.nocodb.com/fields/field-types/formula/date-functions#month', validation: { args: { rqd: 1, @@ -409,6 +415,8 @@ export const formulas: Record = { returnType: FormulaDataTypes.STRING, }, HOUR: { + docsUrl: + 'https://docs.nocodb.com/fields/field-types/formula/date-functions#hour', validation: { args: { rqd: 1, @@ -1171,6 +1179,8 @@ export const formulas: Record = { syntax: 'REGEX_MATCH(string, regex)', examples: ['REGEX_MATCH({title}, "abc.*")'], returnType: FormulaDataTypes.NUMERIC, + docsUrl: + 'https://docs.nocodb.com/fields/field-types/formula/string-functions#regex_match', }, REGEX_EXTRACT: {