你当前正在访问 Microsoft Azure Global Edition 技术文档网站。 如果需要访问由世纪互联运营的 Microsoft Azure 中国技术文档网站,请访问 https://docs.azure.cn。
dayofweek()
Applies to: ✅ Microsoft Fabric ✅ Azure Data Explorer ✅ Azure Monitor ✅ Microsoft Sentinel
Returns the number of days since the preceding Sunday, as a timespan
.
To convert timespan
to int
, see Convert timespan to integer.
Syntax
dayofweek(
date)
Learn more about syntax conventions.
Parameters
Name | Type | Required | Description |
---|---|---|---|
date | datetime |
✔️ | The datetime for which to determine the day of week. |
Returns
The timespan
since midnight at the beginning of the preceding Sunday, rounded down to an integer number of days.
Examples
The following example returns 0, indicating that the specified datetime is a Sunday.
print
Timespan = dayofweek(datetime(1947-11-30 10:00:05))
Output
Timespan |
---|
00:00:00 |
The following example returns 1, indicating that the specified datetime is a Monday.
print
Timespan = dayofweek(datetime(1970-05-11))
Output
Timespan |
---|
1.00:00:00 |
Convert timespan to integer
The following example returns the number of days both as a timespan
and as data type int
.
let dow=dayofweek(datetime(1970-5-12));
print Timespan = dow, Integer = toint(dow/1d)
Output
Timespan | Integer |
---|---|
2.00:00:00 | 2 |