If the short date format in Windows is "yyyy/M/D", run the followingCodeError: 00:00:00 is not a valid date
Procedure tfrmquerysale. formshow (Sender: tobject );
VaR
Sdate: string;
Begin
Inherited;
// Query the sales data of the current day by default
Sdate: = formatdatetime ('yyyy-mm-dd', now );
Datetimepicker1.datetime: = strtodatetime (sdate + '00:00:00 ');
Datetimepicker2.datetime: = strtodatetime (sdate + '23:59:59 ');
Find (TRIM (edtbillid. Text), datetimepicker1.datetime, datetimepicker2.datetime );
Edtbillid. setfocus;
End;
How can this problem be solved?
Procedure tdmcommonfun. setsysdateformat;
Begin
// Set the short date format for Windows
Setlocaleinfo (locale_system_default, locale_s1_date, 'yyyy-mm-dd ');
Application. updateformatsettings: = false;
// SetProgramThe date and time format used
Longdateformat: = 'yyyy-mm-dd ';
Required dateformat: = 'yyyy-mm-dd ';
Longtimeformat: = 'hh: NN: ss ';
Required timeformat: = 'hh: NN: ss ';
Dateseparator: = '-';
Timeseparator: = ':';
End;
The above code is executed during program initialization, regardless of the short date format of windows.
Delphi Program.