Board index » delphi » 0.0 is not a valid Timestamp
Brian Huff
Delphi Developer |
Brian Huff
Delphi Developer |
0.0 is not a valid Timestamp2005-11-16 05:01:49 AM delphi77 Hi all, I am porting an app from D4 to Delphi 7 and the ugly "0.0 is not a valid Timestamp" error has raised it is head. I have looked all over the net and have seen this issue come up, but no good way to solve it seems to present itself. This is basically a null date issue (using ADS Database) and the error seems to trip in the SysUtils.pas unit. Any suggestions? Brian |
John Herbster
Delphi Developer |
2005-11-16 06:55:49 AM
Re:0.0 is not a valid Timestamp
"Brian Huff" <XXXX@XXXXX.COM>wrote
QuoteHi all, I am porting an app from D4 to Delphi 7 and ... of these newsgroups. -- JohnH newsgroup list & guidelines info.borland.com/newsgroups/ |
Liz
Delphi Developer |
2005-11-16 02:24:45 PM
Re:0.0 is not a valid Timestamp
Brian Huff writes:
QuoteThis is basically a null date issue (using ADS Database) and the Liz the Brit Delphi things I have released: www.xcalibur.co.uk/DelphiThings |
Brian Huff
Delphi Developer |
2005-11-16 10:54:56 PM
Re:0.0 is not a valid Timestamp
Unfortunatly there are none, otherwise this would be a much easier
operation. Brian "Liz" <XXXX@XXXXX.COM>writes QuoteBrian Huff writes: |
Brian Huff
Delphi Developer |
2005-11-16 10:55:16 PM
Re:0.0 is not a valid Timestamp
Thank you for pointing that out...
Brian "John Herbster" <herb-sci1_AT_sbcglobal.net>writes Quote
|
Liz
Delphi Developer |
2005-11-16 11:19:21 PM
Re:0.0 is not a valid Timestamp
Brian Huff writes:
QuoteUnfortunatly there are none, otherwise this would be a much easier -- Liz the Brit Delphi things I have released: www.xcalibur.co.uk/DelphiThings |
Ingvar Anderberg
Delphi Developer |
2005-11-17 03:15:33 AM
Re:0.0 is not a valid Timestamp
"Brian Huff" <XXXX@XXXXX.COM>skrev i meddelandet news:437a4c52$XXXX@XXXXX.COM...
QuoteHi all, I am porting an app from D4 to Delphi 7 and the ugly "0.0 is not a valid /ia |
Brian Huff
Delphi Developer |
2005-11-17 04:50:34 AM
Re:0.0 is not a valid Timestamp
I think the result I am going to end up going with is a quick util that will
launch during the install/upgrade process of our product which will correct the date fields in question. Just was hoping not to have to do that. Thanks for replies Liz! Brian "Liz" <XXXX@XXXXX.COM>writes QuoteBrian Huff writes: |
Brian Huff
Delphi Developer |
2005-11-17 04:52:24 AM
Re:0.0 is not a valid Timestamp
Not a locale setting, though that is a good thought.
After doing more research what it boils down to is that Delphi 4 allows a tDateTime := 0; operation to happen, which then gets translated in Advantage Database Server as 0/0/0000 which then will kick out an error in Delphi 6 and up. It's a bad way to null out a date if you ask me, but that was done years ago. Brian "Ingvar Anderberg" <XXXX@XXXXX.COM>writes Quote
|
Ingvar Anderberg
Delphi Developer |
2005-11-17 05:02:55 AM
Re:0.0 is not a valid Timestamp
"Brian Huff" <XXXX@XXXXX.COM>skrev i meddelandet news:437b9b9a$XXXX@XXXXX.COM...
QuoteNot a locale setting, though that is a good thought. if (db.field = 0) then db.field.Clear; /ia |
Ingvar Anderberg
Delphi Developer |
2005-11-17 05:06:12 AM
Re:0.0 is not a valid Timestamp
"Ingvar Anderberg" <XXXX@XXXXX.COM>skrev i meddelandet
Quote
|
Brian Huff
Delphi Developer |
2005-11-19 03:31:21 AM
Re:0.0 is not a valid Timestamp
That's what the util that we wrote does. We have three products that need
it, so it is a bear. But we cycle through the entire database and check every field that is a DateTime field and blank it out if the value is 0/0/0000. We do this with a Delphi 4 util during the install/upgrade. That works just fine. After more testing and research, it boils down to code now. The util will handle the database side of things and dates already establed wrong. But there is some code that does this: Var dPeriod_End : TDateTime begin dPeriod_End := -693594.0; //Assign to 0 date if dPeriod_End <= SOMEDATEVAR then begin Do Some Stuff end else begin Post dPeriod_End to a database field. end; It's that Post dPeriod_End to a database field that is messing the whole thing up. the -693594.0 is used (why I have no idea, it was done way before my time) to establish 0 as a base date to compare some other dates to. If the other dates are greater than 0 then we work with those, otherwise we post that damn 0 date to the database field. Delphi 7 WILL let you post it, but if you try to access it again (with a data aware component) you get the 0.0 not valid time stamp error. We have 357 instances in our code in one project alone that does this, and they are huge, so I am not wanting to spend two months going through all our code to fix it. The fix that we are looking at now, is hitting the BeforePost on our table object to check that there are no values like 0/0/0000 etc going in, otherwise, we'll change em then. Brian Huff Travis Software "Ingvar Anderberg" <XXXX@XXXXX.COM>writes Quote
|
Ingvar Anderberg
Delphi Developer |
2005-11-19 04:56:40 AM
Re:0.0 is not a valid Timestamp
"Brian Huff" <XXXX@XXXXX.COM>skrev i meddelandet news:437e2b8d$XXXX@XXXXX.COM...
QuoteThat's what the util that we wrote does. We have three products that need Why don't you change the value to -693593.0 as the base date, it will then be year 1, i.e 01/01/0001 and will pass the test. /ia |
charles
Delphi Developer |
2005-11-20 07:47:50 PM
Re:0.0 is not a valid Timestamp
Brian Huff writes:
QuoteHi all, I am porting an app from D4 to Delphi 7 and the ugly "0.0 is not a valid the update, then convert it back after updating? Charles -- www.the-{*word*104}-zone.com - it is a personal thing :-) |
Brian Huff
Delphi Developer |
2005-11-21 11:29:05 PM
Re:0.0 is not a valid Timestamp
You know, it is always the easiest solutions that elude us.
Changing to -693593.0 from -693594.0 did indeed work like a charm... and it keeps the integrity of my many hundred calculations in tact. Ingvar, thank you very much for the simple idea. I have a very very bad habbit of replacing all the plumbing in my house simply to fix a leaky faucet. Brian Huff "Ingvar Anderberg" <XXXX@XXXXX.COM>writes Quote
|