COleDateTime::SetDate

int SetDate( int nYear, int nMonth, int nDay );

Return Value

Zero if the value of this COleDateTime object was set successfully; otherwise, 1. This return value is based on the DateTimeStatus enumerated type. For more information, see the SetStatus member function.

Parameters

nYear, nMonth, nDay

Indicate the date components to be copied into this COleDateTime object.

Remarks

Call this member function to set the date and time of this COleDateTime object. The date is set to the specified values. The time is set to time 0, midnight.

See the following table for bounds for the parameter values:

Parameter Bounds
nYear 100 – 9999
nMonth 1 – 12
nDay 1 – 31

The actual upper bound for nDay values varies based on the month and year. For months 1, 3, 5, 7, 8, 10, and 12, the upper bound is 31. For months 4, 6, 9, and 11, it is 30. For month 2, it is 28, or 29 in a leap year.

If the date value specified by the parameters is not valid, the status of this object is set to invalid and the value of this object is not changed.

Here are some examples of date values:

nYear nMonth nDay Value
1995 4 15 15 April 1995
1789 7 14 17 July 1789
1925 2 30 Invalid
10000 1 1 Invalid

To set both date and time, see COleDateTime::SetDateTime.

For information on member functions that query the value of this COleDateTime object, see the following member functions:

For more information about the bounds for COleDateTime values, see the article Date and Time: Automation Support in Visual C++ Programmer’s Guide.

COleDateTime OverviewClass MembersHierarchy Chart

See Also   COleDateTime::COleDateTime, COleDateTime::SetDateTime, COleDateTime::operator =, COleDateTime::GetStatus, COleDateTime::m_dt