Search on date in query?

Search on date in query?

Post by RnJhbm » Sun, 12 Jun 2005 05:36:02

I have noticed that the date properties in the NameSpaces for WebDAV are
"" fields. For example, when I perform a query to get back emails
from my inbox they come back in the response XML as follows:

<d:datereceived b:dt="">2005-06-10T20:04:46.000Z</d:datereceived>

Notice the date is in the format yyyy-mm-dd then follows the letter T, then
the time in military format (along with the milliseconds) and then a Z.

I am trying to tell my query to only bring back email that are 30 days old
(so I can eventually do a DELETE method on them.) I calculate the datetime
for 30 days ago from the current datetime, attempt to format it into this
same format, and place this into a string variable named sOldDate. I then
use this in my WHERE clause:

"urn:schemas:httpmail:datereceived"" < " & sOldDate

I get back a request status of 400 telling me it's a Bad Request. I've
tried everything I know to format this date or just use a regular date
mm-dd-yyyy with & without the datetime and it always fails.

Any ideas?

Thank you very much for your time,


Search on date in query?

Post by Henning Kr » Sun, 12 Jun 2005 06:40:57

Hello Frank,

you can do a search on dates with this where clause:

WHERE ("urn:schemas:httpmail:datereceived" <
CAST("2005-03-21T00:00:00.000Z" as 'dateTime'))

Note that you can't use a < or > sign directly, you must mask it as an
entity (< becomes < and > becomes >)
Then you must cast the date you are comparing to datetimt in the query.

Henning Krause [MVP - Exchange]
Visit my website:
Try my free Exchange Explorer: Mistaya
( )


Search on date in query?

Post by RnJhbm » Wed, 15 Jun 2005 06:02:07

Thank you! It worked perfectly. Only thing was since I'm using the
createTextNode method of my DOM document object and providing it a query
string, it magically takes the < and inputs < (which fails). So, not
knowing how to add the node correctly when it contains an Entity, I worked
around it. If there is a special way to create nodes with Entities into DOM
documents, please let me know.