Deterministic scalar function to get day of week for a date

后端 未结 11 1600
孤街浪徒
孤街浪徒 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:42

    Not sure what you are looking for, but if this is part of a website, try this php function from http://php.net/manual/en/function.date.php

    function weekday($fyear, $fmonth, $fday) //0 is monday
    {
      return (((mktime ( 0, 0, 0, $fmonth, $fday, $fyear) - mktime ( 0, 0, 0, 7, 17,   2006))/(60*60*24))+700000) % 7;
    }
    

提交回复
热议问题