Page 1 of 1

PostgreSQL and datestyle

Posted: Sat 21 Aug 2010 05:25
by 99Percent
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?

Posted: Sat 21 Aug 2010 09:29
by AlexP
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