Q&A

  • 요일구하는데 에러가 나네요 봐주세염

소스는 이렇구요
============함수부분=========
function TForm4.dateDayOfWeek(D: TDateTime): TDayOfWeek;
begin
  Result := TDayOfWeek(Pred(DayOfWeek(D)));
end;

var
  ldt_date : Tdatetime ;
  begin
  with DM.Query7  do begin
   close;
   sql.Clear;
   sql.add('SELECT SYSDATE');
   sql.add('FROM DUAL');
   open;
   end;

ldt_date :=  DM.query7.fieldbyname('SYSDATE').AsDateTime;
showmessage(datetimetostr(dateDayOfWeek(ldt_date)));  ====> 에러발생

에러가 나더라구요

[Error] Unit4.pas(175): Incompatible types: 'TDateTime' and 'TDayOfWeek'

요런 에러가요

우찌 해결해야하는지 어디가 틀렸는지 모르겠네염

답변 부탁드립니다.

1  COMMENTS
  • Profile
    고지범 2002.09.19 22:41
    델파이 헬프의 예제입니다.
    타입이 혼동되신 듯....

    VCL Reference
    StrToDate, DayOfWeek Example

    procedure TForm1.Button1Click(Sender: TObject);
    var
      ADate: TDateTime;
      days: array[1..7] of string;
    begin
      days[1] := 'Sunday';
      days[2] := 'Monday';
      days[3] := 'Tuesday';
      days[4] := 'Wednesday';
      days[5] := 'Thursday';
      days[6] := 'Friday';
      days[7] := 'Saturday';
      ADate := StrToDate(Edit1.Text);
      ShowMessage(Edit1.Text + ' is a ' + days[DayOfWeek(ADate)];
    end;            
                                        ^^^^^^^^^^^^^^^^^^^^^^^^^