Browse Source

feat: add DAY function support(PG)

pull/7268/head
Pranav C 1 year ago
parent
commit
a5938eebd5
  1. 10
      packages/nocodb-sdk/src/lib/formulaHelpers.ts
  2. 11
      packages/nocodb/src/db/functionMappings/pg.ts

10
packages/nocodb-sdk/src/lib/formulaHelpers.ts

@ -396,6 +396,16 @@ const formulas: Record<string, FormulaMeta> = {
examples: ['DATESTR({column1})'],
returnType: FormulaDataTypes.STRING,
},
DAY: {
validation: {
args: {
rqd: 1,
},
},
description: 'Formats a datetime into a string (YYYY-MM-DD)',
examples: ['DATESTR({column1})'],
returnType: FormulaDataTypes.STRING,
},
DATETIME_DIFF: {
validation: {
args: {

11
packages/nocodb/src/db/functionMappings/pg.ts

@ -139,7 +139,16 @@ const pg = {
builder: knex.raw(
`TO_DATE(${
(await fn(pt?.arguments[0])).builder
}, 'YYYY-MM-DD') ${colAlias}`,
}, 'YYYY-MM-DD')::text ${colAlias}`,
),
};
},
DAY: async ({ fn, knex, pt, colAlias }: MapFnArgs) => {
return {
builder: knex.raw(
`EXTRACT('Day' FROM DATE ${
(await fn(pt?.arguments[0])).builder
}) ${colAlias}`,
),
};
},

Loading…
Cancel
Save