OData Azure Search DateTime Format

Working with Azure Search and building filter string in OData, needing to feed current date and time, you can do;

string filter = “filterfield ge ” + DateTime.Now.ToString(“yyyy-MM-dd’T’HH:mm:ss-00:00”); ;

Reference: https://msdn.microsoft.com/en-us/library/azure/dn798921.aspx

 

One Reply to “OData Azure Search DateTime Format”

  1. This is a nice quick tip. I know that C#’s ToString method doesn’t go directly to the OData V4 format used by Azure Search. To this day, I still have to lookup this format template whether I’m using JavaScript or C# :). I wrote some Azure Search Training and I’m still looking up this template :).

Leave a Reply