Q:

Filter DateTime with ExecSQL

I'm applying this filter:
var date = new DateTime(2019, 06, 20).ToUniversalTime().ToString("dd/MM/yyyy HH:mm");
MAPITable mt = session.Stores.MAPITable;
mt.Item = inbox.Items;

var records = mt.ExecSQL($"select Subject, EntryID from Inbox Where \"urn:schemas:httpmail:datereceived\" > {date}");

I'm having this exception:

An unhandled exception of type 'System.Runtime.InteropServices.COMException' occurred in ConsoleApplication1.exe

Additional information: Unsupported operator: /
Should it be possible to do this kind of filter? [With > operator]

A:

You need to make sure the date variable is SQL formatted and encoded in single quotes.

