PostgreSQL and datestyle

Discussion of open issues, suggestions and bugs regarding UniDAC (Universal Data Access Components) for Delphi, C++Builder, Lazarus (and FPC)
Post Reply
99Percent
Posts: 48
Joined: Tue 13 Sep 2005 05:34

PostgreSQL and datestyle

Post by 99Percent » Sat 21 Aug 2010 05:25

I have noticed that Unidac TUniQuery ignores the postgresql server's datestyle setting and instead relies on the Windows regional settings. This is not acceptable behavior for my application.

The server's datestyle is "ISO, YMD'; yet when I query a date field I get "mm/dd/yyyy" asstring unless I change the computer's regional setting for the date format.

How can I fix this?

AlexP
Devart Team
Posts: 5530
Joined: Tue 10 Aug 2010 11:35

Post by AlexP » Sat 21 Aug 2010 09:29

Hello,

The datetime data is stored in database as number,
The text value of date is got with TDateTimeField.GetText function (see the DB unit).

If you want to get specific date format you can use
1. In the grid you should set UniQueryYOUR_DATE_FIELD.DisplayFormat := 'format as you need'
For more information about DispalyFormat read the Delphi help about 'TDateTimeField.DisplayFormat'

2. In query: SELECT to_char("YOUR_DATE_FIELD", 'format as you need')
More about Postgres Data Type Formatting Functions you can read in
http://developer.postgresql.org/pgdocs/ ... tting.html

Post Reply