質問

I'm using Delphi 2007.

I need write a FormatDateTime function that always return 01/01/ to a TDateEdit box (DevExpress component) as EditValue.

I've already tried...

tcxDateEdit1.EditValue := FormatDateTime('01/01/'+ 'yyyy',now);

and

tcxDateEdit1.EditValue := FormatDateTime('01/01/yyyy',Now);

but none of them worked. It result in an error of converting variant of type string to double. "Could not convert variant of type (String) into type (Double)"

役に立ちましたか?

解決

I'm only guessing but your EditValue property seems to be of TDateTime (or TDate) type (while FormatDateTime returns a string). If that's true you could try the following:

tcxDateEdit1.EditValue := EncodeDate(YearOf(Now), 1, 1);

See also: YearOf, EncodeDate, FormatDateTime documentation

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top