CTField::SetFieldDefaultDateTimeType
Sets the default field value date and time type.
Declaration
void CTField::SetFieldDefaultDateTimeType(CTDATE_TYPE dateType, CTTIME_TYPE timeType);
Description
CTField::SetFieldDefaultDateTimeType() sets the default field value date and time type to be used when converting CT_DATE, CT_TIME and CT_TIMES string values. By default the date type is CTDATE_MDCY and the time type is CTTIME_HMS. Use this method to modify the default values.
The CTField::SetFieldDefaultDateTimeType() method modifies both the date and time types. If you wish to change only the default date time, but keep the current time type, use the following example:
hField.SetFieldDefaultDateTimeType(CTDATE_YMD, hField.GetFieldDefaultTimeType());
You can use the same approach to change only the time type, keeping the current date type:
hField.SetFieldDefaultDateTimeType(ctdbGetFieldDefaultDateType(),CTIME_HMP);
dateType is the date type to be used for converting values between dates and strings. The possible values are:
Value |
Symbolic Constant |
Explanation |
---|---|---|
1 |
CTDATE_MDCY |
Date format is mm/dd/ccyy |
2 |
CTDATE_MDY |
Date format is mm/dd/yy |
3 |
CTDATE_DMCY |
Date format is dd/mm/ccyy |
4 |
CTDATE_DMY |
Date format is dd/mm/yy |
5 |
CTDATE_CYMD |
Date format is ccyymmdd |
6 |
CTDATE_YMD |
Date format is yymmdd |
timeType is the time type to be used for converting values between time and strings. The possible values are:
Value |
Symbolic Constant |
Explanation |
---|---|---|
1 |
CTTIME_HMSP |
Time format is hh:mm:ss am|pm |
2 |
CTTIME_HMP |
Time format is hh:mm am|pm |
3 |
CTTIME_HMS |
Time format is hh:mm:ss (24 hour) |
4 |
CTTIME_HM |
Time format is hh:mm (24 hour) |
5 |
CTTIME_MIL |
Time format is hhmm (military) |
Example
// set the field default date and time types
try
{
CTField hField = hTable.GetField("country");
hField.SetFieldDefaultDateTimeType(CTDATE_MDCY, CTTIME_HMSP);
}
catch (CTException &err)
{
printf("SetFieldDefaultDateTimeType failed\n");
}
See Also
SetFieldDefaultValue(), GetFieldDefaultValue(), IsFieldDefaultValueSet(), ClearFieldDefaultValue(), ClearAllFieldDefaultValue(), GetFieldDefaultDateType(), GetFieldDefaultTimeType()