Delphi Database, Delphi Components from ComponentAce
Products Download Order Contact us
Formats
Previous  Top  Next



The date, time, number, and currency formats used in your application should be localized for the target locale.
All DB-Aware controls display date, time, number and currency values using the default system locale settings.
The problem could happen when you are specifying a date, time, ... constant in a filter string or in a SQL command.

Then you should remember the following issues:
·Point character ('.') is fixed as a decimal separator.  
·ISO format could be used for date/time constants: YYYY-MM-DD HH:MM:SS to avoid problems with locale settings.  
·In other cases Absolute Database uses the current system locale settings to format date, time, and currency.  

So if you are using date, time, number, or currency in a string format for filtering, searching, or with SQL command, you must use one of the following methods:

·Use the fixed decimal point character '.' for float and currency constants  
·Use the ISO format YYYY-MM-DD for date, HH:MM:SS for time constants  
·Use the default locale settings to convert date, time, ... value to a string  
·Use query parameters  
·Specify the format via special format string and SQL function  


The following example illustrates how you can use the float value in a filter string:

ABSTable1.Filter := 'Weight > 3.5';  
 
 
The code below shows how to use ISO format date constant in SQL query:

ABSQuery1.SQL.Text := 'INSERT INTO Orders (ID, BillDate) VALUES (1, ''2003-07-31'')';  
 
 
The next sample demonstrates how you can use the default locale settings to convert date value to a string for SQL query:

ABSQuery1.SQL.Text := 'INSERT INTO Orders (ID, BillDate) VALUES (1, '+QuotedStr(DateToStr(Date))+')';  
 
 
The code below shows how to use query parameters to avoid converting problems:

ABSQuery1.SQL.Text := 'INSERT INTO Orders (ID, BillDate) VALUES (2, :BillDate)';  
ABSQuery1.Params[0].AsDateTime := Date;  
 
 
The last example illustrates how to use TODATE SQL function to insert DateTime field value:

INSERT INTO Orders (ID, BillDate) VALUES (3, TODATE('12/16/2002 11:10:30 am','MM/DD/YYYY hh:nn:ss ampm'))  
 
 
        © 2003 - 2024 ComponentAce  | .net zip component | barcode for .net | delphi zip component | delphi database Nov 21, 2024