startofyear()

傳回包含該日期的當年開始日期,若有位移的話則移位。

語法

startofyear(date [,offset ])

深入瞭解 語法慣例

參數

名稱 類型 必要 Description
date datetime ✔️ 要尋找年份開始日期的日期。
offset int 要從輸入日期位移的年數。 預設值是 0。

傳回

日期時間表示指定日期值的當年開始時間,若有指定,則會含有位移。

範例

range offset from -1 to 1 step 1
| project yearStart = startofyear(datetime(2017-01-01 10:10:17), offset) 

輸出

yearStart
2016-01-01 00:00:00.0000000
2017-01-01 00:00:00.0000000
2018-01-01 00:00:00.0000000