RoseK
RoseK

Reputation: 23

How to compare values of types string and datetime in Kusto

I have a table 'Incident' and I'm trying to get count of all incidents resolved in the last 12 months based on 'Resolved_at' column which is of type 'String'. I used the below query on Kusto:

Incident

| where resolved_at >= datetime_add('month',1,make_datetime(2020,1,1))

| project resolved_at , severity , number

But I'm getting this error: Semantic error:...has the following semantic error: Cannot compare values of types string and datetime. Try adding explicit casts.

Please suggest.

Upvotes: 2

Views: 13071

Answers (1)

Slavik N
Slavik N

Reputation: 5328

Try todatetime(), for example the following will return true:

todatetime("2020-12-24") == datetime(2020-12-24)

Upvotes: 1

Related Questions