OL98: SetColumns Returns Incorrect Times When Used with TasksID: Q219034
|
When using the SetColumns method to retrieve dates or times from tasks, the times may not accurately reflect what is stored in the task.
With the exception of tasks, all dates in Outlook are stored in Coordinated Universal Time (UTC), also known as Greenwich Mean Time (GMT). However, tasks store dates in local time. The SetColumns method always converts the retrieved time into local time, therefore causing the times to be offset.
HKEY_Local_Machine\SYSTEM\CurrentControlSet\Control\TimeZoneInformationThe Bias value specifies the current bias, in minutes, for local time translation on the computer. The bias is the difference, in minutes, between local time and UTC. Use this value to correct the time retrieved using the SetColumns method.
Microsoft has confirmed this to be a bug in the Microsoft products listed at the beginning of this article.
The Date type is implemented as a floating-point value, measuring days from midnight, December, 30 1899. To interpret the time portion, take the absolute value of the fractional part of the number. Since the bias is measured in minutes however, you must divide the bias by the number of minutes in a day (1440) in order to perform the conversion. The formula is:
For example, the Date value of a task to be started February 14, 1999 (UTC) should be 36205.0. However, if your application is run on a computer in New York, the Date value (local time) will be 36204.7916667 (February 13, 1999 7:00 P.M.). To perform the conversion, find the computer's bias (from the registry), which is 0x0000012c (300 minutes). Using this in the formula, we have:local time + (Bias / 1440 ) = UTC
For more information about using Visual Basic to retrieve values from the registry, please see the following article in the Microsoft Knowledge Base:local time + (Bias / 1440 ) = UTC 36204.7916667 + (300/1440) = 36205.0 (February 13, 1999 7:00 PM + 5hrs) = February 14, 1999 0:00am
Q1456796 HOWTO: Use the Registry API to Save and Retrieve Setting
http://www.microsoft.com/support/supportnet/refguide/
Private Sub Command1_Click()
Dim OutApp As Outlook.Application
Dim oNameSpace As Outlook.NameSpace
Dim oFolder As Outlook.MAPIFolder
Dim oItems As Outlook.Items
Dim oTask As Outlook.TaskItem
Set OutApp = New Outlook.Application
Set oNameSpace = OutApp.GetNamespace("MAPI")
Set oFolder = oNameSpace.GetDefaultFolder(olFolderTasks)
Set oItems = oFolder.Items
Set oTask = oItems("New Task")
MsgBox CDbl(oTask.StartDate)
oItems.SetColumns "StartDate"
Set oTask2 = oItems("New Task")
MsgBox CDbl(oTask2.StartDate)
End Sub
For more information about creating solutions with Microsoft Outlook 98,
please see the following articles in the Microsoft Knowledge Base:
Q180826 OL98: Resources for Custom Forms and Programming
Q182349 OL98: Questions About Custom Forms and Outlook Solutions
Additional query words: OutSol OutSol98 vbscript
Keywords : kbdta OffVBS
Version : WINDOWS:
Platform : WINDOWS
Issue type : kbbug
Last Reviewed: April 6, 1999