user2879125
user2879125

Reputation: 183

Getting the year of the current date

if StrToInt(sY) > 2013 then
begin
  bDate := False;
  ShowMessage('Year is bigger than current year');
  Exit;
end;

This is what I have at this stage but I'm pretty sure there is a way to get the current year instead of having to manually type it in delphi code, would be much appreciated if someone could help me with the code for it.

Upvotes: 10

Views: 50225

Answers (1)

LU RD
LU RD

Reputation: 34939

DateUtils.YearOf(Now) will get you the current year,

or use

SysUtils.CurrentYear.

As @Remy points out, Date is more to the point than Now. So is DateUtils.Today.

Upvotes: 34

Related Questions