What is wrong in my oOutlookAppointment.Find filter?

  • Thread starter Thread starter DENNIS BROWN
  • Start date Start date
D

DENNIS BROWN

Hi,
I can't seem to nail down a problem with my filter in the Find method of Items object.
Here is what I'm doing:

My sFilter string is the following:
sFilter="[Start] >= '08/07/2007' AND [Start] <= '08/08/2007'"
and it returns a single recurring appointment I have on August 7, but not the all day event, and another timed appointment on that same day.
If I do
sFilter="[Start] >= '08/06/2007' AND [Start] < '08/08/2007'"
Then I get all of August 6 recurring, and *all* of August 7 appointments!
All I want is August 7 appointments--all 3 of them.
What am I doing wrong here?
I have the oFolderItems.IncludeRecurrences = TRUE
and oFolderItems.Sort("[Start]")
And I'm setting columns, but the
oOutlookAppointment=oFolderItems.Find(sFilter)
isn't doing what I want it to do!
Any suggestions?
 
Try adding hours and minutes components to your filter (not seconds) and see
how that works. Don't forget that all day events begin at 00:00 of that
date.



Hi,
I can't seem to nail down a problem with my filter in the Find method of
Items object.
Here is what I'm doing:

My sFilter string is the following:
sFilter="[Start] >= '08/07/2007' AND [Start] <= '08/08/2007'"
and it returns a single recurring appointment I have on August 7, but not
the all day event, and another timed appointment on that same day.
If I do
sFilter="[Start] >= '08/06/2007' AND [Start] < '08/08/2007'"
Then I get all of August 6 recurring, and *all* of August 7 appointments!
All I want is August 7 appointments--all 3 of them.
What am I doing wrong here?
I have the oFolderItems.IncludeRecurrences = TRUE
and oFolderItems.Sort("[Start]")
And I'm setting columns, but the
oOutlookAppointment=oFolderItems.Find(sFilter)
isn't doing what I want it to do!
Any suggestions?
 
Are you calling Start before IncludeRecurrences? The order is critical. See http://www.outlookcode.com/article.aspx?id=30

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


Hi,
I can't seem to nail down a problem with my filter in the Find method of Items object.
Here is what I'm doing:

My sFilter string is the following:
sFilter="[Start] >= '08/07/2007' AND [Start] <= '08/08/2007'"
and it returns a single recurring appointment I have on August 7, but not the all day event, and another timed appointment on that same day.
If I do
sFilter="[Start] >= '08/06/2007' AND [Start] < '08/08/2007'"
Then I get all of August 6 recurring, and *all* of August 7 appointments!
All I want is August 7 appointments--all 3 of them.
What am I doing wrong here?
I have the oFolderItems.IncludeRecurrences = TRUE
and oFolderItems.Sort("[Start]")
And I'm setting columns, but the
oOutlookAppointment=oFolderItems.Find(sFilter)
isn't doing what I want it to do!
Any suggestions?
 
Sure am! I found out the hard way!<g>

--

Thanks,
Dennis
Are you calling Start before IncludeRecurrences? The order is critical. See http://www.outlookcode.com/article.aspx?id=30

--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


Hi,
I can't seem to nail down a problem with my filter in the Find method of Items object.
Here is what I'm doing:

My sFilter string is the following:
sFilter="[Start] >= '08/07/2007' AND [Start] <= '08/08/2007'"
and it returns a single recurring appointment I have on August 7, but not the all day event, and another timed appointment on that same day.
If I do
sFilter="[Start] >= '08/06/2007' AND [Start] < '08/08/2007'"
Then I get all of August 6 recurring, and *all* of August 7 appointments!
All I want is August 7 appointments--all 3 of them.
What am I doing wrong here?
I have the oFolderItems.IncludeRecurrences = TRUE
and oFolderItems.Sort("[Start]")
And I'm setting columns, but the
oOutlookAppointment=oFolderItems.Find(sFilter)
isn't doing what I want it to do!
Any suggestions?
 
That did it!
Is times like 00:00 and 23:59 ok, or do I need to use 12:00 AM and 11:59 PM instead? The 00:00 and 23:59 seem to work currently.
Will I run into issues using those on international versions of Outlook?
Also, will the routines work in 2002 and 2003? I'm currently using this in 2007.

--

Thanks,
Dennis
Try adding hours and minutes components to your filter (not seconds) and see how that works. Don't forget that all day events begin at 00:00 of that date.
--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


Hi,
I can't seem to nail down a problem with my filter in the Find method of Items object.
Here is what I'm doing:

My sFilter string is the following:
sFilter="[Start] >= '08/07/2007' AND [Start] <= '08/08/2007'"
and it returns a single recurring appointment I have on August 7, but not the all day event, and another timed appointment on that same day.
If I do
sFilter="[Start] >= '08/06/2007' AND [Start] < '08/08/2007'"
Then I get all of August 6 recurring, and *all* of August 7 appointments!
All I want is August 7 appointments--all 3 of them.
What am I doing wrong here?
I have the oFolderItems.IncludeRecurrences = TRUE
and oFolderItems.Sort("[Start]")
And I'm setting columns, but the
oOutlookAppointment=oFolderItems.Find(sFilter)
isn't doing what I want it to do!
Any suggestions?
 
Don't use AM and PM, use 24-hour time, it works best in almost all language
and internationalization settings.

Outlook (MAPI) stores all date/time values internally as UTC and converts
them when they are used by Outlook to local time. If you aren't directly
accessing MAPI properties (like from PropertyAccessor in Outlook 2007) you
always get local time back. You do get UTC if you work with MAPI props or
PropertyAccessor.

In general it's usually best to test for ranges rather than hard times,
there could be rounding errors or other slight differences where an equality
test would fail where a range test would work.

If you use any of the Outlook 2007 methods that adjust local to UTC or vice
versa you especially have to work with ranges, those functions round a
date/time to the nearest minute, so using those you can't ever expect an
equality test to work.




That did it!
Is times like 00:00 and 23:59 ok, or do I need to use 12:00 AM and 11:59
PM instead? The 00:00 and 23:59 seem to work currently.
Will I run into issues using those on international versions of Outlook?
Also, will the routines work in 2002 and 2003? I'm currently using this
in 2007.
 
Thanks!

--

Thanks,
Dennis
Don't use AM and PM, use 24-hour time, it works best in almost all language and internationalization settings.

Outlook (MAPI) stores all date/time values internally as UTC and converts them when they are used by Outlook to local time. If you aren't directly accessing MAPI properties (like from PropertyAccessor in Outlook 2007) you always get local time back. You do get UTC if you work with MAPI props or PropertyAccessor.

In general it's usually best to test for ranges rather than hard times, there could be rounding errors or other slight differences where an equality test would fail where a range test would work.

If you use any of the Outlook 2007 methods that adjust local to UTC or vice versa you especially have to work with ranges, those functions round a date/time to the nearest minute, so using those you can't ever expect an equality test to work.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007
Reminder Manager, Extended Reminders, Attachment Options
http://www.slovaktech.com/products.htm


That did it!
Is times like 00:00 and 23:59 ok, or do I need to use 12:00 AM and 11:59 PM instead? The 00:00 and 23:59 seem to work currently.
Will I run into issues using those on international versions of Outlook?
Also, will the routines work in 2002 and 2003? I'm currently using this in 2007.
 
Back
Top