Deterministic scalar function to get day of week for a date

后端 未结 11 1602
孤街浪徒
孤街浪徒 2021-01-13 00:10

SQL Server, trying to get day of week via a deterministic UDF.

Im sure this must be possible, but cant figure it out.

UPDATE: SAMPLE CODE..

C         


        
11条回答
  •  日久生厌
    2021-01-13 00:25

    The proposed solution has one problem - it returns 0 for Saturdays. Assuming that we're looking for something compatible with DATEPART(WEEKDAY) this is an issue.

    Nothing a simple CASE statement won't fix, though.

提交回复
热议问题