DateTime issue

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top