开发者

DAYOFWEEK function for SEDE?

The sp开发者_如何学编程ecifications on SQL Azure mention ODBC date and time functions, namely to transform a date to weekday.

Currently, using DAYOFWEEK results in an error message:

SELECT DAYOFWEEK(LastActivityDate) FROM Posts Limit 1;

Error: 'DAYOFWEEK' is not a recognized built-in function name.


DAYOFWEEK is a MySQL function (likewise for LIMIT) - Azure uses Microsoft's TSQL functionality - you want DATEPART:

SELECT TOP 1
       DATEPART(dw, LastActivityDate) 
  FROM Posts

Reference:

  • TOP


I followed the link to the documentation that you gave, and they illustrate the usage as:

SELECT TOP 1
    {fn DAYOFWEEK( LastActivityDate )}
FROM Posts

Example: https://data.stackexchange.com/stackoverflow/query/716136

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜