Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Outlook Restrict on SentOn (using Between)

308 views
Skip to first unread message

McKilty

unread,
Sep 28, 2009, 10:57:58 AM9/28/09
to
Hello all,

I am trying to figure to the proper syntax for using Restrict on the
SentOn field. I need to restrict between two dates, but so far
nothing is filtering to the exact date range I'm looking for. I have
tried:

Set mItemCollection = mItemCollection.Restrict("[SentOn] > '" &
dteStart & "' AND [SentOn] < '" & dteEnd & "'")
Set mItemCollection = mItemCollection.Restrict("[SentOn] = '" &
dteStart & "'")
Set mItemCollection = mItemCollection.Restrict("[SentOn] Between '" &
dteStart & "' AND '" & dteEnd & "'")

Thanks for the help.

Sue Mosher [MVP]

unread,
Sep 28, 2009, 11:22:20 AM9/28/09
to
Only your first statement is workable. Between is not an available operator,
and SentOn includes the time element, not just a date, so you're unlikely to
find an exact match. See http://www.outlookcode.com/article.aspx?id=30. I
recommend that you use a separate statement to build the query string so you
can examine it and, if you continue to have issues with this, post a
specific example in this thread so we can see how you're formatting the
dteStart and dteEnd values.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54


"McKilty" <blues...@gmail.com> wrote in message
news:90bca1e3-225e-49ef...@e18g2000vbe.googlegroups.com...

McKilty

unread,
Sep 28, 2009, 11:47:46 AM9/28/09
to
On Sep 28, 11:22 am, "Sue Mosher [MVP]" <sue...@turtleflock.com>
wrote:

> Only your first statement is workable. Between is not an available operator,
> and SentOn includes the time element, not just a date, so you're unlikely to
> find an exact match. Seehttp://www.outlookcode.com/article.aspx?id=30.  I

> recommend that you use a separate statement to build the query string so you
> can examine it and, if you continue to have issues with this, post a
> specific example in this thread so we can see how you're formatting the
> dteStart and dteEnd values.
> --
> Sue Mosher, Outlook MVP
>    Author of Microsoft Outlook 2007 Programming:
>      Jumpstart for Power Users and Administrators
>    http://www.outlookcode.com/article.aspx?id=54
>
> "McKilty" <bluesbr...@gmail.com> wrote in message

>
> news:90bca1e3-225e-49ef...@e18g2000vbe.googlegroups.com...
>
> > Hello all,
>
> > I am trying to figure to the proper syntax for using Restrict on the
> > SentOn field.  I need to restrict between two dates, but so far
> > nothing is filtering to the exact date range I'm looking for.  I have
> > tried:
>
> > Set mItemCollection = mItemCollection.Restrict("[SentOn] > '" &
> > dteStart & "' AND [SentOn] < '" & dteEnd & "'")
> > Set mItemCollection = mItemCollection.Restrict("[SentOn] = '" &
> > dteStart & "'")
> > Set mItemCollection = mItemCollection.Restrict("[SentOn] Between '" &
> > dteStart & "' AND '" & dteEnd & "'")
>
> > Thanks for the help.

Thanks Sue. Your link was very helpful.

Switching to a string rather than a date made it work.

0 new messages