sos!

renligai 2005-05-08 02:52:49
日期的比较怎么实现啊!
对于日期的年、月、日的读取如何实现?
...全文
106 4 打赏 收藏 转发到动态 举报
写回复
用AI写文章
4 条回复
切换为时间正序
请发表友善的回复…
发表回复
Demogodyou 2005-05-08
  • 打赏
  • 举报
回复
Label1.Caption := 'Today is Day ' + FormatDatetime('dd of Month mm of Year yyyy', now);
Label2.Caption := 'The time is Minute ' + FormatDatetime('mm:ss of Hour hh', now);
yeeyee 2005-05-08
  • 打赏
  • 举报
回复
Indicates the relationship between the date portions of two TDateTime values.

Unit

DateUtils

Category

datetime routines

Delphi syntax:

function CompareDate(const A, B: TDateTime): TValueRelationship;

C++ syntax:

extern PACKAGE Types::TValueRelationship __fastcall CompareDate(const System::TDateTime A,
const System::TDateTime B);

Description

Call CompareDate to compare the two TDateTime values specified by A and B. CompareDate returns

LessThanValue if A occurs on a day prior to the day specified by B.
EqualsValue if A occurs on the same day as B, ignoring the time of day.
GreaterThanValue if A occurs on a day that follows the day specified by B.

//==============================
Returns the day of the month represented by a TDateTime value.

Unit

DateUtils

Category

datetime routines

Delphi syntax:

function DayOf(const AValue: TDateTime): Word;
MonthOf(const AValue: TDateTime): Word;
YearOf(const AValue: TDateTime): Word;

C++ syntax:

extern PACKAGE Word __fastcall DayOf(const System::TDateTime AValue);

Description

Call DayOf to obtain the day of the month represented by a specified TDateTime value. DayOf returns a value between 1 and 31.

Note: DayOf returns the same value as the DayOfTheMonth function.
tdtjjiao 2005-05-08
  • 打赏
  • 举报
回复
now
是现在的日期
date1 > date2
直接比就行了。
ffwin 2005-05-08
  • 打赏
  • 举报
回复
procedure TForm1.Button1Click(Sender: TObject);

var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
+ IntToStr(Month) + ' of Year ' + IntToStr(Year);
DecodeTime(Present, Hour, Min, Sec, MSec);
Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
+ IntToStr(Hour);
end;

5,939

社区成员

发帖
与我相关
我的任务
社区描述
Delphi 开发及应用
社区管理员
  • VCL组件开发及应用社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧