If you need to work a lower level:-
The dayofweek() function will get you a numeric value represnting the day. Use this to index an array of strings holding the day names.
You need to make sure the date entered can be converted to a valid TDatetime value (with Strtodate) then pass this to day of week.
I knocked this up last week to remind my boss to go to the bank you Might find some clues in it.
unit Pay;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type Days = (Sunday,Monday,Tuesday,Wednesday,Thursday,Friday,Saturday);
type
TPayDay = class(TForm)
Button1: TButton;
Display: TLabel;
procedure FormActivate(Sender: TObject);
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
function DayNumToday(Dn: integer): Days;
function Post(D: integer): string;
{ Public declarations }
end;
var
PayDay: TPayDay;
const daynames: array[Sunday..Saturday] of string = ('Sunday','Monday','Tuesday','Wednesday',
'Thursday','Friday','Saturday');
implementation
{$R *.DFM}
procedure TPayDay.FormActivate(Sender: TObject);
var Present: TDateTime;
Year, Month, DayNumber: Word;
Day: Days;
begin
Day := DayNumToDay(DayofWeek(Now));
if Day in [Monday..Friday] then
begin
Present:= Now;
DecodeDate(Present, Year, Month, DayNumber);
case Daynumber of
21: if Day in [Wednesday,Thursday,Friday] then
Display.Visible := true;
22: if day = Wednesday then
Display.Visible := true;
23: if day in [Monday,Tuesday,Wednesday] then
Display.Visible := true;
else Application.Terminate;
end;
end
else
Application.Terminate;
end;
function TPayDay.DayNumToday(Dn: integer): Days;
begin
case Dn of
1: Result := Sunday;
2: Result := Monday;
3: Result := Tuesday;
4: Result := Wednesday;
5: Result := Thursday;
6: Result := Friday;
7: Result := Saturday;
end;
end;
function TPayDay.Post(D: integer): string;
begin
case D of
1,21,31: Result := 'st';
2,22: Result := 'nd';
else Result := 'th';
end;
end;
procedure TPayDay.Button1Click(Sender: TObject);
begin
close;
end;
end.
Steve