COleDateTime

COleDateTime does not have a base class.

A COleDateTime object encapsulates the DATE data type used in OLE automation. It is one of the possible types for the data type of OLE automation. A COleDateTime value represents an absolute date and time value.

The DATE type is implemented as a floating-point value, measuring days from midnight, 30 December 1899. So, midnight, 31 December 1899 is represented by 1.0. Similarly, 6 AM, 1 January 1900 is represented by 2.25, and midnight, 29 December 1899 is – 1.0. However, 6 AM, 29 December 1899 is – 1.25.

Note   To interpret the time portion, take the absolute value of the fractional part of the number.

The COleDateTime class handles dates from 1 January 100 – 31 December 9999.

Note   COleDateTime ignores Daylight Saving Time. See in Visual C++ Programmer's Guide for details.

This type is also used to represent date-only or time-only values. By convention, the date 0 (30 December 1899) is used for time-only values. Similarly, the time 0:00 (midnight) is used for date-only values.

If you create a COleDateTime object with a date less than 100, the date will be accepted, but subsequent calls to GetYear, GetMonth, GetDay, GetHour, GetMinute, and GetSecond will fail and return -1. Previously, you could use two-digit dates, but dates must be 100 or greater in MFC 4.2 and later.

To avoid problems, specify a four-digit date. For example:

COleDateTime.mytime(1996,1,1,0,0,0);

Basic arithmetic operations for the COleDateTime values use the companion class COleDateTimeSpan. COleDateTimeSpan values represent relative time, an interval. The relation between these classes is analogous to the one between CTime and CTimeSpan.

For more information on the COleDateTime and COleDateTimeSpan classes, see the article in Visual C++ Programmer's Guide

#include <afxdisp.h>

Class MembersHierarchy Chart

See Also   COleVariant