startofmonth()

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

語法

startofmonth(date [,offset ])

深入瞭解 語法慣例

參數

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

傳回

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

範例

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

輸出

monthStart
2016-12-01 00:00:00.0000000
2017-01-01 00:00:00.0000000
2017-02-01 00:00:00.0000000