[Overview][Constants][Types][Classes][Procedures and functions][Index] | Reference for unit 'Calendar' (#lcl)

# TCustomCalendar.DateTime

Native data type used for a date value on the calendar control.

## Declaration

Source position: calendar.pp line 124

`public property TCustomCalendar.DateTime : TDateTime read GetDateTime write SetDateTime;`

## Description

DateTime is a TDateTime property with the date value for the calendar control. It determines the initial month and year displayed on the control, and the day of the month highlighted at run-time. It is updated (along with Date) when a new date value is selected using the calendar control.

Reading the value for the property causes both Date and DateTime members to be retrieved from the widgetset class when its handle has been allocated. If the handle is not available, the member value is used instead.

Setting a new value for the property causes the TDateTime value to be validated. When MinDate and MaxDate contain non-zero date/time values that are at least one day apart, the property must in the specified range limits. When MinDate and MaxDate are not assigned, the RTL MinDateTime and MaxDateTime constants are used to limit the range for the date value. An EInvalidDate exception is raised when the date value is not valid for the data type, or not within the required range.

FormatDateTime is called to convert the TDateTime value to its string representation in Date. An EConvertError exception is raised if the date is not valid or DefaultFormatSettings contains an invalid ShortDate format.

Changes to the property values are sent to the widgetset class instance when its handle has been allocated. This includes values in the Date, DateTime, MinDate, MaxDate, DisplaySettings, and FirstDayOfWeek properties.

Use the OnChange, OnDayChanged, OnMonthChanged, or OnYearChanged event handlers to perform actions needed when the date (and its component values) has been modified in the widget for the calendar control.

Remark: | The control does not use the time portion of the TDateTime data type. The time value is not significant unless the specified time is not valid for the date/time data type.

## Errors

EConvertError is raised when the value is not a valid for the TDateTime type.

EInvalidDate is raised when the date value is not within the range represented by MinDate and MaxDate; raised with the message rsInvalidDateRangeHint.

## See also

TCustomCalendar.Date |  | String representation for the date value on the calendar control.
TCustomCalendar.MinDate |  | Smallest date value that can entered or selected using the calendar control.
TCustomCalendar.MaxDate |  | Largest date value that can entered or selected using the calendar control.
TCustomCalendar.OnChange |  | Event handler signalled when the calendar control has been changed.
TCustomCalendar.OnYearChanged |  | Event handler signalled when the year number in DateTime has been changed using the calendar control.
TCustomCalendar.OnMonthChanged |  | Event handler signalled when the month number in DateTime has been changed using the calendar control.
TCustomCalendar.OnDayChanged |  | Event handler signalled when the day number in DateTime has been changed using the calendar control.