I am writing a kusto query in azure which extracts data from a column called RawData and puts that date into another column(Date). Now this Date column has the date data but it is in string format. How to convert it into date format so i can apply date functions on it?
UserLogs
| project Date=substring(RawData, 0, 22), RawData
| project Date, RawData=substring(RawData, 24, 150)
| where RawData has "Login" and Date > ago(15m)
whose result look like :-
Using todatetime()
you can covert a column datatype to date format. After converting column to date any date functions can be applied.
Sample code
datatable (Computer: string,RawData : string) [
"h01","2023-04-06 09:42:00.154 Login by user abc",
"h02","2023-04-06 09:42:00.154 Login by user Jeff",
"h09","2023-04-06 09:42:00.154 Login by user predom"
]
| project Date=todatetime(substring(RawData, 0, 22)), RawData=substring(RawData, 24, 150)
| where RawData has "Login" and Date > ago(15m)
Result
Result schema