Link to home
Start Free TrialLog in
Avatar of Paul Brooks
Paul BrooksFlag for United Kingdom of Great Britain and Northern Ireland

asked on

Week of the year

Can anybody please give me an example of how to use the weekoftheyear routine. I have read the help file and it is as clear as mud. I have a date in a dateTime picker and i need to calculate the week No for a choosen date. I can see there is a routine that i can use but i just cant figure out how to use it

Many thanks
SOLUTION
Avatar of kretzschmar
kretzschmar
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
var
  w, y : word;
begin
  w := WeekOf(DateTimePicker1.Date);
  ShowMessage('Week no = ' + inttostr(w));
  w := WeekOfTheYear(DateTimePicker1.Date); // Returns same as above
  ShowMessage('Week no = ' + inttostr(w));
  w := WeekOfTheYear(DateTimePicker1.Date, y); // same as above but y will have the year in which the returned   ShowMessage('Week no = ' + inttostr(w) + ' Year=' + inttostr(y));
week falls. To see the effect of year (last call) set the date to 1 jan 2006 and then set it to 2 jan 2006
end;
var
  w, y : word;
begin
  w := WeekOf(DateTimePicker1.Date);
  ShowMessage('Week no = ' + inttostr(w));
  w := WeekOfTheYear(DateTimePicker1.Date); // Returns same as above
  ShowMessage('Week no = ' + inttostr(w));
  w := WeekOfTheYear(DateTimePicker1.Date, y); // same as above but y will have the year in which the returned     week falls. To see the effect of year (last call) set the date to 1 jan 2006 and then set it to 2 jan 2006
ShowMessage('Week no = ' + inttostr(w) + ' Year=' + inttostr(y));
end;