D dg_hy Unregistered / Unconfirmed GUEST, unregistred user! 2009-12-27 #1 操作系统日期格式为YYYY-MM-DD,在程序中某一字符串S1的格式为YYYY/MM/DD,现在想将其转化为YYYY-MM-DD显示,如何进行。如果使用StrtoDate先行将S1转化为日期,会报错。
K kaida Unregistered / Unconfirmed GUEST, unregistred user! 2009-12-27 #3 procedure TForm1.Button1Click(Sender: TObject);var dt: TDateTime;begin DateSeparator := '/'; ShortDateFormat := 'YYYY/MM/DD'; dt := StrToDate('2009/12/27'); ShortDateFormat := 'yyyy-M-D'; ShowMessage(DateTimeToStr(dt)); //to testend;
procedure TForm1.Button1Click(Sender: TObject);var dt: TDateTime;begin DateSeparator := '/'; ShortDateFormat := 'YYYY/MM/DD'; dt := StrToDate('2009/12/27'); ShortDateFormat := 'yyyy-M-D'; ShowMessage(DateTimeToStr(dt)); //to testend;