How do we add time offsets to datetime value in Kusto? As an example, I have table with the time in UTC and offset values.
utcStartDateTime uctOffset
2020-04-16T00:00:25Z 08:00:00
2020-04-16T00:00:47Z 10:00:00
I would like to add them. I tried the below with no luck.
datetime_add('hour',datetime_part('hour', todatetime(utcOffset)),todatetime(utcStartDateTime))
The below works but it is good for only hourly offsets.
datetime_add('hour', toint(split(utcOffset, ":" )[0]),todatetime(utcStartDateTime))
Ideally, datetime values would be typed as datetime, and timespan values would be typed as timespan, and then you can simply add them
the following example assumes the worst, i.e. both your columns are typed as string (based on how you attempted to solve it in your original question)
datatable(utcStartDateTime:string, uctOffset:string)
[
'2020-04-16T00:00:25Z', '08:00:00',
'2020-04-16T00:00:47Z', '10:00:00'
]
| extend date_with_offset = todatetime(utcStartDateTime) + totimespan(uctOffset)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With