microsoft / Kusto-Query-Language

Kusto Query Language is a simple and productive language for querying Big Data.
Apache License 2.0
510 stars 97 forks source link

format_datetime datetime expected #59

Closed albertoRamon closed 2 years ago

albertoRamon commented 2 years ago

This works:

ADFActivityRun
| where TimeGenerated > ago(3d)
| extend  duration2 = (End - Start)

image

This fail:

 ADFActivityRun
| where TimeGenerated > ago(3d)
 extend duration2 = format_datetime((End - Start),'y-M-d h:m:s.fffffff')

image image\ image

Redundant but just in case, fail too

 ADFActivityRun
| where TimeGenerated > ago(3d)
extend duration2 = format_datetime((todatetime(End) - todatetime(Start)),'y-M-d h:m:s.fffffff')

image

sloutsky commented 2 years ago

The function format_datetime() expects datetime value (as error described). For formating timespans: use https://docs.microsoft.com/en-us/azure/data-explorer/kusto/query/format-timespanfunction

albertoRamon commented 2 years ago

End and Start, is date time End - Start, is date time

and just in case: todatetime(start) is datetime

sloutsky commented 2 years ago

If End is datetime - and Start is datetime, then End-Start is timespan

albertoRamon commented 2 years ago

ohh, thanks !!