能否只显示年或只显示年和月? DateTimePicker控件显示的格式如:2004-3-21, 我想问一下能不能让它显示成:2004,或显示成:2004-3 ? 先谢谢了! 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 formatDateTime('yyyy',DateTimePicker.date)//显示年formatDateTime('mm',DateTimePicker.date)//显示月formatDateTime('dd',DateTimePicker.date)//显示日formatDateTime('yyyy年mm月dd日',DateTimePicker.date)//显示年月日formatDateTime('yyyy-mm-dd',DateTimePicker.date)//显示年月日 formatDateTime('yyyy-mm',DateTimePicker.date)//显示年月formatDateTime('yyyy-MM-dd hh:mm:ss ',DateTimePicker.date)//显示年月日小时 DateTimePicker只有显示年月日或者时间两种格式楼上的方法行不通 在Datetimepicker里好像不能满足你的要求哟。 Datetimepicker可以的设置format属性为 yyyy-M 就可以 修改Format属性DateTimePicker1.Format := 'yyyy';//2004DateTimePicker1.Format := 'yyyy-MM';//2004-03 就用 FormatDatetime格式吧 这个最好了 DateTimePicker1.Format := 'yyyy-MM';//2004-03DateTimePicker1.Format := 'yyyy-M';//2004-3//注意M要大写不然显示的是分钟,楼上的写错了! 首先谢谢大家,大家说的方法在Delphi7里可以,可是我用的是Delphi5,DateTimePicker 好象没有format这个属性呀。 用formatDateTime('yyyy',DateTimePicker.date)编译是正确的,但显示格式还是没有改变。 请问在Delphi5里有办法能处理这个问题吗? To:: ln521(智者天王) ,能说具体一些吗? 一開始, 先設置下, 看如何?begin DateSeparator := '-'; ShortDateFormat := 'yyyy-M'; Label1.Caption := DateToStr(Date);end; To:aiirii(ari-爱的眼睛) ,我是想用DateTimePicker显示,不是用label。 公布源码,关于定时器发送/计数源码 ★★★★★DELPHI全体版主预祝大家圣诞快乐,新年快乐★★★★★ 我的delphi7不能用Ctrl+Space激活Code Completion 一个StringGrid的焦点的问题 如何用delphi打开word,excel,PowerPoint,能给个例子吗,谢谢 分栏的报表怎么做??? 我要在Delphi中添加TRaveDataText组件,请问要添加那个单元? 求助。。。。串口奇偶校验问题(急!) for循环 InterBase库*.gdb问题 那位兄台知道一个软件的使用期限一般都写在注册表的那个地方? 有关treeview
formatDateTime('mm',DateTimePicker.date)//显示月
formatDateTime('dd',DateTimePicker.date)//显示日formatDateTime('yyyy年mm月dd日',DateTimePicker.date)//显示年月日formatDateTime('yyyy-mm-dd',DateTimePicker.date)//显示年月日
formatDateTime('yyyy-MM-dd hh:mm:ss ',DateTimePicker.date)//显示年月日小时
楼上的方法行不通
设置format属性为 yyyy-M 就可以
DateTimePicker1.Format := 'yyyy';//2004
DateTimePicker1.Format := 'yyyy-MM';//2004-03
DateTimePicker1.Format := 'yyyy-M';//2004-3
//注意M要大写不然显示的是分钟,楼上的写错了!
用formatDateTime('yyyy',DateTimePicker.date)编译是正确的,但显示格式还是没有改变。
请问在Delphi5里有办法能处理这个问题吗?
begin
DateSeparator := '-';
ShortDateFormat := 'yyyy-M';
Label1.Caption := DateToStr(Date);
end;