Reputation: 4302
I am trying to restrict the kusto datetime to yyyy-MM-dd hh:mm. However, I see that:
print todatetime((format_datetime(datetime(2015-12-14 00:03:04.12345), 'yyyy-MM-dd hh:mm')))
and
print todatetime((format_datetime(datetime(2015-12-14 12:03:04.12345), 'yyyy-MM-dd hh:mm')))
both return 2015-12-14 12:03:00.0000000. How do I fix this?
Upvotes: 3
Views: 5490
Reputation: 1
Use HH
instead of hh
.
You can try this:
print todatetime((format_datetime(datetime(2015-12-14 12:03:04.12345), 'yyyy-MM-dd HH:mm')))
Upvotes: 0
Reputation: 25895
a datetime
-typed value will always include milli/micro/seconds (even if their value is 0
). todatetime()
always returns a datetime
-typed value.
if you want to format a datetime
-typed value using a specific format, you'll have to keep it as a string
, and use the format_datetime()
function as you did above.
print string_value = format_datetime(datetime(2015-12-14 00:03:04.12345), 'yyyy-MM-dd hh:mm')
Upvotes: 4