str:=FormatDateTime('yyyy"-"mm"-"dd',Mydate);

解决方案 »

  1.   

    哪个地方不对?
    以下代码经过检验:
        Label1.Caption:=FormatDateTime('yyyy"-"mm"-"dd',DateTimePicker1.Date);
      

  2.   

    直接在主窗口OnCreate时间中添加如下代码:
      ShortDateFormat:=LongDateFormat;
    也可以设成另外的形式。
      

  3.   

    var lpstime: TSystemTime;
    begin
    getLocaltime(lpSTime);
    syearlabel.Caption :=inttostr(lpstime.wYear);
    smoulabel.Caption :=inttostr(lpstime.wMonth);
    sdaylabel.Caption :=inttostr(lpstime.wDay);
    shourlabel.Caption :=inttostr(lpstime.wHour);
    sminlabel.Caption :=inttostr(lpstime.wMinute);
    sseclabel.Caption :=inttostr(lpstime.wSecond);
    end;这里的wyear 本来就是4位的,何必那么麻烦呢。
      

  4.   

    我也来插一句:以下代码是从Help里抄来的:
    procedure TForm1.Button1Click(Sender: TObject);begin
      DateSeparator := '-';
      DateFullYear := True;
      DateLeadZero := True;
      Label1.Caption := DateToStr(Date);
    end;
    可是实际运行的时候,编译却说DateSeparator DateFullYear DateLeadZero ‘undeclared’还要在前面声明什么吗?