user2967251
user2967251

Reputation: 191

Converting string to datetime in KQL

I have a column with a string representing a datetime, where the month name is 3 letters, and there's the time zone info. How do I convert it into a datetime?

"Jul 13 2020 23:05:58 GMT" --> 2020-07-13T23:05:58.000

Upvotes: 5

Views: 23250

Answers (2)

Simao Gomes Viana
Simao Gomes Viana

Reputation: 631

Simpler way of doing what Yoni suggested:

print dt = todatetime("Jul 13 2020 23:05:58 GMT")

Upvotes: 2

Yoni L.
Yoni L.

Reputation: 25895

This will create a table with a single string column, with a single sample record (for the sake of answering your question)

.set Ts <| print s = "Jul 13 2020 23:05:58 GMT"

This will convert each string value in that column/table from string to datetime

Ts
| extend dt = todatetime(s)

enter image description here

relevant docs:

Upvotes: 11

Related Questions