Browse Source

chore: revise weekday logic using mod

pull/2706/head
Wing-Kam Wong 2 years ago
parent
commit
82d47b4d93
  1. 7
      packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/functionMappings/mysql.ts

7
packages/nocodb/src/lib/db/sql-data-mapper/lib/sql/functionMappings/mysql.ts

@ -68,12 +68,7 @@ const mysql2 = {
};
const offset = m[pt?.arguments[1]?.value.toLowerCase()] || 0;
return knex.raw(
`CASE
WHEN WEEKDAY(${fn(pt.arguments[0])}) >= ${offset} THEN
WEEKDAY(${fn(pt.arguments[0])}) - ${offset}
ELSE
7 - ${offset} + WEEKDAY(${fn(pt.arguments[0])})
END${colAlias}`
`(WEEKDAY(${fn(pt.arguments[0])}) - ${offset} % 7 + 7) % 7 ${colAlias}`
);
},
};

Loading…
Cancel
Save