0
votes

I've got an assignment to do which involves seeing if there are any birthdays this month. I'm 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

3

3 Answers

1
votes

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

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

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.

1
votes

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.