开发者

Get current month as number in Pascal

I've got an assignment to do which involves seeing if there are any birthdays this month. I'm开发者_JS百科 not asking for you to 'do my homework', but what I am asking is this: is there a way to get the current month as a number from 1-12 in Pascal (specifically, Lazarus Pascal)? Then I can take the number and compare it with records held in file.

Thanks for any help,

James


I don't know about Lazarus, but most Pascal implementations provide:

procedure GetDate(var Year, Month, Day, DayofWeek: Word); 


You can use this code:

DecodeDate(Date:TDateTime, Year, Month, Day: word);

I recommend you to check dateutils unit. It provides full support for all "date" or "time" issues.


Manny is right. I just tried it in Lazarus, by writing this procedure:

procedure Dates;
var y, m, d: word;
begin
  DecodeDate(Date, y, m, d);
end;

Date is a function in SysUtils (datih.inc) that returns the current local date. DecodeDate is a procedure that takes a TDateTime and returns to var parameters the calendar values of year. month and day. You need all 3 of course, but just use the one you need.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜