Reputation: 3713
I'm working on an application that requires the following regional settings (Delphi 7 and PostgreSQL 9.0):
1. DateSeparator:='/';
2. TimeSeparator:=':';
3. ThousandSeparator:=',';
4. DecimalSeparator:='.';
5. ShortDateFormat:='MM/dd/yy';
6. ShortTimeFormat:='hh:mm:ss';
I need to change the regional setting only for my application and not system wide.
In OnCreate of the form I set the above separators, and my current system separators are:
1. DateSeparator='|';
2. TimeSeparator='|';
3. ThousandSeparator='|';
4. DecimalSeparator='|';
(This is for the test purpose.)
Now in Postgres I have a table from where I get dates to display in my application but somehow the dateseparator doesn't seem to work (as seen in label1)!
Check the image.
I fire a query to get the dates from the table
Label1.Caption:=(Fields(1).Text);
Label2.Caption:=datetostr(Fields(1).Data) ;
The query is
select min(dat), max(dat) from diary where survey in (2008401) and event not in ('E','C','R') and region=6100;
now the same date if I take as .data differ in the date separator from .text dateseparator why this is happening?
Why are the regional settings not applied to label1.caption
(as shown in the image)?
Upvotes: 0
Views: 2958
Reputation: 3713
ok i found on one site
enter link description here
for getting the appropriate format all i had to do was get the fire the query as
select to_char(min(dat),'mm/dd/yy'), to_char(min(dat),'mm/dd/yy')
from diary
where survey in (2008401) and
event not in ('E','C','R') and region=6100;
This gave me the proper result in the format i wanted
Upvotes: 1
Reputation: 125669
DateToStr
uses ShortDateFormat
as the output format. You didn't change that from the MM/dd/yy
set initially; you only changed the DateSeparator
.
I'm confused though, about why you'd want to use (Fields(1).Text)
(is that right? Parentheses instead of [] for the Fields subscript?).
If the DB is configured to use |
as the date separator, as it appears it is from your screen image, why are you using DateToStr
? It appears that .Text
is getting the information in the format you're looking to obtain.
Upvotes: 1