Prevent Delphi programs from being affected by the Windows Date Format

Source: Internet
Author: User

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.

 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.