DateTime issues

P

Pete W

microsoft C# 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. This
Works OK.
i.e dt.ToString("MM/dd/yyyy")

Why should the time part of the date cause grief?

cheers

Peter
 
P

Pete W

I really am blind. There was no hour to my dateTime string. I appreciate
your help and will look at the other newsgroup.

cheers

peter
Sue Mosher said:
Remove the seconds element. You can use hours and minutes.

FYI, there is a newsgroup specifically for general Outlook programming
issues "down the hall" at microsoft.public.outlook.program_vba or, via web
interface, at
http://www.microsoft.com/office/community/en-us/default.mspx?dg=microsoft.public.outlook.program_vba

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Pete W said:
microsoft C# 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.
This Works 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

Similar Threads


Top