Found Discussion about and function named DATEDIFF360 here: TOPIC_ID=105375 in the old forum

Checked it, has issues.

Did it in plain T-SQL, as primitivly as possible...

Note that below code does not aim at constituting any new way of calculating a 360-Day-Year but at mimicking the behaviour of excel's DAYS360 Function, but omitting the inconsistencies

(As the 28th of Feb is a special case, below code-example uses that day)

SELECT

*

,(MonthsBetweenStartAndEndMonth+AddFullStartMonth+AddFullEndMonth)*30+AddDaysOfStartMonth+AddDaysOfEndMonth as DateDiff360

FROM

(

select

'2022-02-28' as StartDay

,'2022-06-30' as EndDay

,DATEDIFF(MONTH, '2022-02-28', '2022-06-30') as MonthDiff

, DATEDIFF(MONTH, '2022-02-28', '2022-06-30') -1 as MonthsBetweenStartAndEndMonth

, CASE WHEN DAY('2022-02-28') = 1 THEN 1 ELSE 0 END as AddFullStartMonth

, CASE WHEN DAY('2022-06-30') = DAY(Eomonth('2022-06-30')) THEN 1 ELSE 0 END as AddFullEndMonth

,CASE WHEN DAY('2022-02-28') = 1 THEN 0

ELSE

30-DAY('2022-02-28')

--> excel fails if EndDay is 28th of Feb and on some other occasions

--> optional: add 1 day to INCLUDE both Start and End Day in calc: 31-DAY('2022-02-28')

END as AddDaysOfStartMonth

,CASE WHEN DAY('2022-06-30') = DAY(Eomonth('2022-06-30')) THEN 0 ELSE DAY('2022-06-30') END as AddDaysOfEndMonth

) as base