|
|
@ -1,3 +1,4 @@ |
|
|
|
|
|
|
|
import dayjs from 'dayjs'; |
|
|
|
import { MapFnArgs } from '../mapFunctionName'; |
|
|
|
import { MapFnArgs } from '../mapFunctionName'; |
|
|
|
import commonFns from './commonFns'; |
|
|
|
import commonFns from './commonFns'; |
|
|
|
import { getWeekdayByText } from '../helpers/formulaFnHelper'; |
|
|
|
import { getWeekdayByText } from '../helpers/formulaFnHelper'; |
|
|
@ -113,7 +114,11 @@ const mssql = { |
|
|
|
// DATEPART(WEEKDAY, DATE): sunday = 1, monday = 2, ..., saturday = 7
|
|
|
|
// DATEPART(WEEKDAY, DATE): sunday = 1, monday = 2, ..., saturday = 7
|
|
|
|
// WEEKDAY() returns an index from 0 to 6 for Monday to Sunday
|
|
|
|
// WEEKDAY() returns an index from 0 to 6 for Monday to Sunday
|
|
|
|
return knex.raw( |
|
|
|
return knex.raw( |
|
|
|
`(DATEPART(WEEKDAY, ${fn(pt.arguments[0])}) - 2 - ${getWeekdayByText( |
|
|
|
`(DATEPART(WEEKDAY, ${ |
|
|
|
|
|
|
|
pt.arguments[0].type === 'Literal' |
|
|
|
|
|
|
|
? `'${dayjs(fn(pt.arguments[0])).format('YYYY-MM-DD')}'` |
|
|
|
|
|
|
|
: fn(pt.arguments[0]) |
|
|
|
|
|
|
|
}) - 2 - ${getWeekdayByText( |
|
|
|
pt?.arguments[1]?.value |
|
|
|
pt?.arguments[1]?.value |
|
|
|
)} % 7 + 7) % 7 ${colAlias}` |
|
|
|
)} % 7 + 7) % 7 ${colAlias}` |
|
|
|
); |
|
|
|
); |
|
|
|