DateTime issue

  • Thread starter Thread starter Pete W
  • Start date Start date
P

Pete W

microsoft outlook example is
// Set the criteria for the Date fields.
sCriteria = "[Start] <= '09/01/2002 08:00 AM' and [End] >=
'2/15/2002 08:00 PM'";

my code is as follows where dt=DateTime.Now.Subtract(new
TimeSpan(14,0,0,0,0)):
string Filter = "[To] = 'blahblah.co.uk' and [Subject] = 'RE: yadiya" + "
and [SentOn] >= '" + dt.ToString("MM/dd/yyyy mm:ss tt") + "'";

Outlook.MailItem mi=(Outlook.MailItem)SentFolder.Items.Find(Filter);

This fails.
I change the date to have dd/MM/yyyy mm:ss tt, still fails
I change the date to have yyyy/MM/dd mm:ss tt, still fails
If I remove the minutes and seconds plus am/pm stuff and just use date it is
OK. i.e dt.ToString("MM/dd/yyyy")

Why should the time part of the date cause grief?

cheers

Peter
 
Back
Top