设置字段显示格式的方法

((TDateField *)(ADOQuery1->Fields->Fields[0]))->DisplayFormat="yyyymmdd";

格式字符串(来自CB的HELP)

Controls the formatting of the date-time field for display purposes.

__property AnsiString DisplayFormat = {read=FDisplayFormat, write=SetDisplayFormat};

Description

Use DisplayFormat to specify the formatting string to use for formatting the value in a date-time field when the field抯 value appears as a string. If DisplayFormat is not assigned a string, the value is formatted according to the default date-time format.

Note: DisplayFormat does not affect the value of the AsString property.

Construct a DisplayFormat string using these format specifiers:

Specifier Displays

c The date using the format given by the ShortDateFormat global variable, followed by the time using the format given by the LongTimeFormat global variable. The time is not displayed if the fractional part of the DateTime value is zero.
d The day as a number without a leading zero (1-31).
dd The day as a number with a leading zero (01-31).
ddd The day as an abbreviation (Sun-Sat) using the strings given by the ShortDayNames global variable.
dddd The day as a full name (Sunday-Saturday) using the strings given by the LongDayNames global variable.

ddddd The date using the format given by the ShortDateFormat global variable.
dddddd The date using the format given by the LongDateFormat global variable.
m The month as a number without a leading zero (1-12). If the m specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.
mm The month as a number with a leading zero (01-12). If the mm specifier immediately follows an h or hh specifier, the minute rather than the month is displayed.

mmm The month as an abbreviation (Jan-Dec) using the strings given by the ShortMonthNames global variable.
mmmm The month as a full name (January-December) using the strings given by the LongMonthNames global variable.
yy The year as a two-digit number (00-99).
yyyy The year as a four-digit number (0000-9999).
h The hour without a leading zero (0-23).
hh The hour with a leading zero (00-23).
n The minute without a leading zero (0-59).
nn The minute with a leading zero (00-59).

s The second without a leading zero (0-59).
ss The second with a leading zero (00-59).
t The time using the format given by the ShortTimeFormat global variable.
tt The time using the format given by the LongTimeFormat global variable.
am/pm The time using the 12-hour clock for the preceding h or hh specifier, followed by "am" for any hour before noon, or "pm" for any hour after noon. The am/pm specifier can use lower, upper, or mixed case, and the result is displayed accordingly.

a/p The time using the 12-hour clock for the preceding h or hh specifier, followed by "a" for any hour before noon, or "p" for any hour after noon. The a/p specifier can use lower, upper, or mixed case, and the result is displayed accordingly.
ampm The time using the 12-hour clock for the preceding h or hh specifier, followed by the contents of the TimeAMString global variable for any hour before noon, or the contents of the TimePMString global variable for any hour after noon.

/ The date separator character given by the DateSeparator global variable.
: The time separator character given by the TimeSeparator global variable.
'xx'/"xx" Characters enclosed in single or double quotes are displayed as-is, with no formatting changes.


Format specifiers may be written in uppercase or lowercase letters; both produce the same result.

If the string given by the Format parameter is empty, the date and time value is formatted as if a c format specifier had been given.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值