17

If I've got a Kusto datetime and I want to remove the time portion, leaving just a date at midnight, what's the best way? I can do this

todatetime(format_datetime( now(), "yyyy-MM-dd"))

but surely there's a more efficient way?

Rory
  • 40,559
  • 52
  • 175
  • 261
  • Your question is confusing because you first stated that you want to remove the time part entirely (as shown in your code example), but then you indicated that you want "at midnight", which is a time part. – SendETHToThisAddress May 11 '21 at 20:26

1 Answers1

24

Use the startofday() function:

startofday( now() )

or the bin() function:

bin( now(), 1d )
Rory
  • 40,559
  • 52
  • 175
  • 261