PostgreSQL date formatting error

The alpha/beta tester's forum for ZeosLib 7.0.x series

Report problems concerning our Delphi 2009+ version and new Zeoslib 7.0 features here.

This is a forum that will be removed once the 7.X version goes into stable!!

Moderators: gto, EgonHugeist, olehs

markus
Senior Boarder
Senior Boarder
Posts: 54
Joined: 17.10.2011, 12:43
Location: Piotrków Trybunalski, Poland

PostgreSQL date formatting error

Postby markus » 14.01.2013, 16:32

Hi,

I've encountered problem with date fields when i changed datestyle variable of my DB.

usually i work with datestyle=ISO, YMD, but now i needed
datestyle=SQL ,MDY

with such settings postgresql returns date fields like this: 1/14/2013

With such result i get 'Invalid argument to date encode'.

When i looked under the hood i found out that in ZSysUtils.pas
function TimestampStrToDateTime(String)
arbitrary decodes date in order Year, Month, Date.
With my text of '1/14/2013' i get Year=1, Month=14 and Day=2013 and this causes error.

Maybe this function should check ShortDateFormat to see what is order of date elements?

Best regards,
Marek

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 14.01.2013, 21:20

markus,

that's an issue i was waiting for, Marek. Well the current way of Zeos allways adapts to the local settings. But there are some mor DBRMs like Oracle or MSSQL which can change the Data/Time-Format with the current session.

Another example: http://www.lazarus.freepascal.org/index ... 521.0.html

etc.

I was thinking several times about it. Your ShortDateFormat won't match all cases. Example: 11.11.11. What is year, Month, and day?

The datestyle you've changed: Is it session dependend?

IMHO a new Property like DateTimeFormat for our TZConnection or TZDataSet Components would be the best option. Any other, better proposals?
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image

markus
Senior Boarder
Senior Boarder
Posts: 54
Joined: 17.10.2011, 12:43
Location: Piotrków Trybunalski, Poland

Postby markus » 14.01.2013, 21:39

Michael,

You are right ShortDateFormat would be good if DB date formatting would be just like system locale settings, but it might be completely different
Your example is actually vey simple - it doesn't matter which field is year month or day;)

But property of connection is a good idea - it will be formated just as developer needs:)

Regards,
Marek

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 14.01.2013, 22:06

markus,

Your example is actually vey simple - it doesn't matter which field is year month or day;)

YES it was an example of a nerd! :lol:

But it shows clearly what i mean. 8)

Well we've Zeos7.1-alpha and we can implement such a FormatSetting. But currently i'm running over all web-sites and bug-trackers to close issue reports or support some people with Zeos.

So it can take a while...
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image

markus
Senior Boarder
Senior Boarder
Posts: 54
Joined: 17.10.2011, 12:43
Location: Piotrków Trybunalski, Poland

Postby markus » 14.01.2013, 22:23

ok, thank you Michael.

In that case i make myself quick patch based on my first suggestion: ShortDateFormat, which will work good for me.

And when You find time to patch this properly i'll gladly download it:)

Best regards,
Marek

User avatar
EgonHugeist
Zeos Dev Team
Zeos Dev Team
Posts: 1701
Joined: 31.03.2011, 22:38

Postby EgonHugeist » 13.07.2013, 00:15

markus,

i made a patch on 7.2. Simply adde Dateformat='mm-dd-yyy' to the Connection.Properties. Timeformat and DatetimeFormat is supported too now.
King regards, Michael

You want to help? viewtopic.php?f=4&t=3671
You found a (possible) bug? Use the new bugtracker dude! http://sourceforge.net/p/zeoslib/tickets/

Image


Return to “ZeosLib 7.0 Beta Forum”

Who is online

Users browsing this forum: Bing [Bot] and 1 guest