dbedit type 28/02/2006 after the post it shows 31/12/1899
use Lazarus 0.9.12, Zeoslib 6.5.1 cvs and PostgreSQL 8.1.3, have an application that I type a date in the pattern dd/mm/yyyy in the dbedit and does it come back me 31/12/1899, in the database it does show 0001-12-30 BC, where is the error?
in Dataset of Dbedit or in Zeoslib?
respectfully
Silvio Guedes
dbedit type 28/02/2006 after the post it shows 31/12/1899
Moderators: gto, cipto_kh, EgonHugeist
For Delphi's Tdatetime 31/12/1899 is just zero (you remember, digits in front of decimal separator: date, behind decimal separator: time). What's the "starting point" (zero) for PostgreSQL? Maybe 0001-12-30 BC? That would mean that the value gets lost on the way to the database.
I remember having read here about problems with date conversion ("old" format vs. "new" format) in the combination of Zeos/Lazarus/FPC/PostgreSQL, and somebody had a patch for that.
Regards,
Rüdiger
I remember having read here about problems with date conversion ("old" format vs. "new" format) in the combination of Zeos/Lazarus/FPC/PostgreSQL, and somebody had a patch for that.
Regards,
Rüdiger
I always enter date values as yyyy-mm-dd which seems to cause no problem with any dbms. Have you checked the Postgres documentation for valid date formats? Maybe it doesn't support dd/mm/yyyy at all? Can you switch to yyyy-mm-dd or maybe use a non-db-sensitive TEdit and then parse the date to the other format before sending it to the database?
Stefan
Stefan
-
- Junior Boarder
- Posts: 42
- Joined: 24.08.2005, 12:54
- Location: The Most Oriental Point of America - João Pessoa - Brazil
- Contact:
Hello Stefan
how does it can in Delphi 7 the dbedit to work perfectly well and in Lazarus this does happen?
the format of date dd/mm/yyyy in the delphi 7 works because the date is recorded correctly, I type 01/03/2006 in the delphi with the dbedit he records in the postgres 03/01/2006, because in the postgres the format is mm/dd/yyyy in the case using the pgadmin.
could you help me?
after I met the tools opensource I don't intend to never again abandon them, and to contribute in the best possible way for your growth.
Respectfully
Silvio Guedes
how does it can in Delphi 7 the dbedit to work perfectly well and in Lazarus this does happen?
the format of date dd/mm/yyyy in the delphi 7 works because the date is recorded correctly, I type 01/03/2006 in the delphi with the dbedit he records in the postgres 03/01/2006, because in the postgres the format is mm/dd/yyyy in the case using the pgadmin.
could you help me?
after I met the tools opensource I don't intend to never again abandon them, and to contribute in the best possible way for your growth.
Respectfully
Silvio Guedes
At least we can locate the problem now.. Unfortunately, I do not have Lazarus. If I may pass the question on to someone who does..
However, have you tried to use yyyy-mm-dd as a workaround?
If all else fails, I'd try using a non-sensitive TDateTimePicker, read the date from the db on formshow and write the altered date with an UPDATE statement using the execSQL method, e.g.
I admit it's not exactly elegant, but it might help.
Stefan
However, have you tried to use yyyy-mm-dd as a workaround?
If all else fails, I'd try using a non-sensitive TDateTimePicker, read the date from the db on formshow and write the altered date with an UPDATE statement using the execSQL method, e.g.
Code: Select all
UPDATE yourtable SET datecol='2006-02-28' WHERE primarekeycol=xy
Stefan