A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

AdvancedSearch filter with a particular date



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old June 27th 07, 01:22 PM posted to microsoft.public.outlook.program_vba
nana
external usenet poster
 
Posts: 11
Default AdvancedSearch filter with a particular date

Hi,
I am having a problem that if my filter is set to a particular date, my
AdvancedSearch will not return any result.
But if it's set to a range, it is working fine. Is that the normal behavior?
Here is my code.

strScope = "Inbox";
strFilter = "urn:schemas:httpmail:datereceived = '27.06.2007'";
strTag = "Search";
searchResult = OutlookApplication.AdvancedSearch(strScope, strFilter,
'False', strTag);


If the filter is set to

strFilter = "urn:schemas:httpmail:datereceived = '26.06.2007' And
urn:schemas:httpmail:datereceived = '27.06.2007'"

I get the mails of both 26th and 27th of June.
Any idea?


Ads
  #2  
Old June 27th 07, 03:24 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default AdvancedSearch filter with a particular date

Yes, that makes sense. It is unlikely that you have any messages received with a date/time of exactly 27.06.2007 00:00. Try using this filter:

strFilter = "urn:schemas:httpmail:datereceived = '27.06.2007 12:00AM' And urn:schemas:httpmail:datereceived '28.06.2007 12:00AM'"

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


"nana" wrote in message ...
Hi,
I am having a problem that if my filter is set to a particular date, my
AdvancedSearch will not return any result.
But if it's set to a range, it is working fine. Is that the normal behavior?
Here is my code.

strScope = "Inbox";
strFilter = "urn:schemas:httpmail:datereceived = '27.06.2007'";
strTag = "Search";
searchResult = OutlookApplication.AdvancedSearch(strScope, strFilter,
'False', strTag);


If the filter is set to

strFilter = "urn:schemas:httpmail:datereceived = '26.06.2007' And
urn:schemas:httpmail:datereceived = '27.06.2007'"

I get the mails of both 26th and 27th of June.
Any idea?


  #3  
Old July 23rd 07, 03:52 PM posted to microsoft.public.outlook.program_vba
nana
external usenet poster
 
Posts: 11
Default AdvancedSearch filter with a particular date

Hello Sue,
An additional question with the format of the filter.
In the case below, I will only be able to get a correct result if my filter
has the same date format as set in the local machine, is that true?
I have tried to set my machine format to yyyy-mm-dd but keep the search
criteria as described below, there is an error thrown.
Is there any generic way to set the filter that is independent from the date
format ?
Or do I have to read what the current settings of outlook/windows is before
setting the filter?
Thanks!



"Sue Mosher [MVP-Outlook]" wrote:

Yes, that makes sense. It is unlikely that you have any messages received with a date/time of exactly 27.06.2007 00:00. Try using this filter:

strFilter = "urn:schemas:httpmail:datereceived = '27.06.2007 12:00AM' And urn:schemas:httpmail:datereceived '28.06.2007 12:00AM'"

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


"nana" wrote in message ...
Hi,
I am having a problem that if my filter is set to a particular date, my
AdvancedSearch will not return any result.
But if it's set to a range, it is working fine. Is that the normal behavior?
Here is my code.

strScope = "Inbox";
strFilter = "urn:schemas:httpmail:datereceived = '27.06.2007'";
strTag = "Search";
searchResult = OutlookApplication.AdvancedSearch(strScope, strFilter,
'False', strTag);


If the filter is set to

strFilter = "urn:schemas:httpmail:datereceived = '26.06.2007' And
urn:schemas:httpmail:datereceived = '27.06.2007'"

I get the mails of both 26th and 27th of June.
Any idea?



  #4  
Old July 23rd 07, 05:06 PM posted to microsoft.public.outlook.program_vba
Sue Mosher [MVP-Outlook]
external usenet poster
 
Posts: 11,651
Default AdvancedSearch filter with a particular date

It's been a while since I've played with date formats, but I think you should use a generic format, such as dd mmm yyyy format. Also in the example below, I forgot to surround the property names with quotation marks and had the wrong operators. This should be better:

strFilter = Chr(34) & "urn:schemas:httpmail:datereceived" & Chr(34) & _
" '27 Jun 2007 12:00AM' And " & Chr(34) & _
"urn:schemas:httpmail:datereceived" & Chr(34) & " = '28.06.2007 12:00AM'"

You can also use the Filter dialog for a view to create a working filter as a model and then copy the query string from the SQL tab.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"nana" wrote in message ...
Hello Sue,
An additional question with the format of the filter.
In the case below, I will only be able to get a correct result if my filter
has the same date format as set in the local machine, is that true?
I have tried to set my machine format to yyyy-mm-dd but keep the search
criteria as described below, there is an error thrown.
Is there any generic way to set the filter that is independent from the date
format ?
Or do I have to read what the current settings of outlook/windows is before
setting the filter?
Thanks!



"Sue Mosher [MVP-Outlook]" wrote:

Yes, that makes sense. It is unlikely that you have any messages received with a date/time of exactly 27.06.2007 00:00. Try using this filter:

strFilter = "urn:schemas:httpmail:datereceived = '27.06.2007 12:00AM' And urn:schemas:httpmail:datereceived '28.06.2007 12:00AM'"



"nana" wrote in message ...
Hi,
I am having a problem that if my filter is set to a particular date, my
AdvancedSearch will not return any result.
But if it's set to a range, it is working fine. Is that the normal behavior?
Here is my code.

strScope = "Inbox";
strFilter = "urn:schemas:httpmail:datereceived = '27.06.2007'";
strTag = "Search";
searchResult = OutlookApplication.AdvancedSearch(strScope, strFilter,
'False', strTag);


If the filter is set to

strFilter = "urn:schemas:httpmail:datereceived = '26.06.2007' And
urn:schemas:httpmail:datereceived = '27.06.2007'"

I get the mails of both 26th and 27th of June.
Any idea?



  #5  
Old March 17th 10, 02:35 PM posted to microsoft.public.outlook.program_vba
Ron
external usenet poster
 
Posts: 128
Default AdvancedSearch filter with a particular date

Hi Sue,

I am trying to do something similar with a filter but rather a date range
I am looking to filter on a time range for any date.

For example I want to see emails in a folder that were either
sent/received between 10:00 - 17:00 and then again see which ones were not
sent in that range.

Is there a method for putting wild cards in the search string?


"Sue Mosher [MVP-Outlook]" wrote:

It's been a while since I've played with date formats, but I think you should use a generic format, such as dd mmm yyyy format. Also in the example below, I forgot to surround the property names with quotation marks and had the wrong operators. This should be better:

strFilter = Chr(34) & "urn:schemas:httpmail:datereceived" & Chr(34) & _
" '27 Jun 2007 12:00AM' And " & Chr(34) & _
"urn:schemas:httpmail:datereceived" & Chr(34) & " = '28.06.2007 12:00AM'"

You can also use the Filter dialog for a view to create a working filter as a model and then copy the query string from the SQL tab.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"nana" wrote in message ...
Hello Sue,
An additional question with the format of the filter.
In the case below, I will only be able to get a correct result if my filter
has the same date format as set in the local machine, is that true?
I have tried to set my machine format to yyyy-mm-dd but keep the search
criteria as described below, there is an error thrown.
Is there any generic way to set the filter that is independent from the date
format ?
Or do I have to read what the current settings of outlook/windows is before
setting the filter?
Thanks!



"Sue Mosher [MVP-Outlook]" wrote:

Yes, that makes sense. It is unlikely that you have any messages received with a date/time of exactly 27.06.2007 00:00. Try using this filter:

strFilter = "urn:schemas:httpmail:datereceived = '27.06.2007 12:00AM' And urn:schemas:httpmail:datereceived '28.06.2007 12:00AM'"



"nana" wrote in message ...
Hi,
I am having a problem that if my filter is set to a particular date, my
AdvancedSearch will not return any result.
But if it's set to a range, it is working fine. Is that the normal behavior?
Here is my code.

strScope = "Inbox";
strFilter = "urn:schemas:httpmail:datereceived = '27.06.2007'";
strTag = "Search";
searchResult = OutlookApplication.AdvancedSearch(strScope, strFilter,
'False', strTag);


If the filter is set to

strFilter = "urn:schemas:httpmail:datereceived = '26.06.2007' And
urn:schemas:httpmail:datereceived = '27.06.2007'"

I get the mails of both 26th and 27th of June.
Any idea?




 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to get all events for a perticular date, (need exact filter) tushar.p.marathe@gmail.com Add-ins for Outlook 3 April 19th 07 10:02 PM
AdvancedSearch Filter Syntax for Advanced Date Search on Appointme StephenCarterMCP Outlook and VBA 1 February 20th 07 02:19 PM
Filter/Schema to use for AdvancedSearch of Drap/Drop Files EricTempPA Outlook and VBA 0 June 29th 06 10:24 PM
AdvancedSearch filter: cannot search "to" by smtpaddress? Sue Mosher [MVP-Outlook] Outlook and VBA 1 February 9th 06 08:04 PM
AdvancedSearch Serg Flic Outlook and VBA 1 January 10th 06 04:17 PM


All times are GMT +1. The time now is 08:53 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.