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
精彩评论