SQL 2000 exchange link server time is wrong

I have sql server 2000 running on my exchange box so that I can run query's on some people's email box for a customer managment system. I have the mailboxes attached as linked servers and run the following query to make a view.

SELECT     *
FROM         OPENQUERY(Stacy,
                      'SELECT
"urn:schemas:mailheader:date" AS DateSent,
"urn:schemas:mailheader:To" AS MailheaderTo,
"urn:schemas:httpmail:to" AS To,
"urn:schemas:mailheader:from" AS FROM,
"urn:schemas:mailheader:subject" AS Subject,
"urn:schemas:httpmail:datereceived" AS DateReceived,
"urn:schemas:httpmail:fromemail" AS FromEmail,
"urn:schemas:httpmail:fromname" AS FromName,
"urn:schemas:httpmail:textdescription" AS Body,
"urn:schemas:httpmail:htmldescription" AS HTML,
"urn:schemas:mailheader:message-id" as ID
FROM Inbox
WHERE "urn:schemas:httpmail:fromemail" IS NOT NULL')
                       Rowset_1


My problem is that the DateSent is in the future by about 6 hours. The time on the exchange server is correct, so why is the date in the database hours ahead of where it should be?

D--
poulsborvAsked:
Who is Participating?
 
Chris MangusDatabase AdministratorCommented:
Check this link.

http://windowssdk.msdn.microsoft.com/library/default.asp?url=/library/en-us/cdosys/html/_cdosys_imessage_senton.asp

It very briefly describes some time zone issues and also talks about how urn:schemas:calendar:timezoneid can be used to determine what time zone your exchange server really think's it's in.
0
 
Chris MangusDatabase AdministratorCommented:
I'll bet your timezone is GMT-6 (CST / MDT), isn't it?  Email servers typically store email with a datetime stamp that corresponds to GMT time.  You're going to have to account for that in your query.
0
 
poulsborvAuthor Commented:
Do you mean in SQL or on the server itself? The server is set to GMT Pacific time like it should be... checking the sql server
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
poulsborvAuthor Commented:
Where do I check it in the sql server?
0
 
Chris MangusDatabase AdministratorCommented:
Well that's interesting! :)  I would have assumed you were in CST / MDT time zone.  Since you're in GMT Pacific Time zone is would expect your query to be showing DateSent as your local time + 7 hours, not 6.

When I query my exchange servers I get GMT from mailheader:date and I have to subtract 7 hours because I am in MST.  This is because email is stored with a datetime stamp corresponding to GMT time when it was sent.  This is all regardless of how the time zone is set on your exchange server.  When Outlook displays the email it will take into account your time zone and display a date time that is GMT + or - your time zone.

There is no setting of time in SQL Server.  When you run the GetDate() function it will return the current system time.
0
 
poulsborvAuthor Commented:
Well I fudged it a little bit and stopped using the sent date from the exchange server. When I run the query now, which I do every 5 minutes I just date it with now() so that I am with in 5 minutes of when they actually sent it. Thanks for your help cmanqus.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.