PostgreSQL date formatting error
Posted: 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
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