Question

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)"

Was it helpful?

Solution

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top