Reputation: 2106
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)"
Upvotes: 4
Views: 2464
Reputation: 37211
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
Upvotes: 5