Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 214709
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T18:24:01+00:00 2026-05-11T18:24:01+00:00

When I use the following code in a newly inserted record in a TClientDataSet:

  • 0

When I use the following code in a newly inserted record in a TClientDataSet:

cdsMyDateField.OldValue <> Null

I get an EConvertError:

''0.0' is not a valid timestamp'.

Looking at Delphi’s VCL’s code, it tries to convert the value to TDateTime which results in this Exception because the value (Null) is an invalid DateTime, but as I’m comparing Variants I thought that it would return a variant, which would be Null in this case, but that doesn’t happen, instead I get this exception.

I know that I can just check if the DataSet.State = dsInsert before comparing the values, as if the State = dsInsert every OldValue is Null, but I want to understand why the OldValue tries to convert the value instead of Just returning Null in all Fields when the State = dsInsert.

Can anyone please give me some light?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-11T18:24:02+00:00Added an answer on May 11, 2026 at 6:24 pm

    FWIW, I’ve run into this same problem and it caused me several headaches. My opinion: The behaviour is inconsistent so even from that reason alone I class it as a bug. It’s also a bug because raising an exception on reading a property is IMHO ridiculous and not in keeping with the intent of properties (principle of least surprise.) I’d expect OldValue to be Unassigned, not raise an exception on read. (Also, the fact that some issue has existed for a long time does not imply anything about whether or not it’s a bug.)

    (Edit: Updating my answer with more information including our workaround. Also posted same to the QC report: http://qc.embarcadero.com/wc/qcmain.aspx?d=73852 )

    We’ve also had this same problem in an app that makes heavy use of datasnap/clientdatasets. The actual problem however is not with the clientdataset, but with the Timestamp validation routine in SysUtils that apparently erroneously validates a Timestamp with a 0.0 value as invalid.

    The workaround/fix is hence to SysUtils and the validation routine, and not to Tclientdataset Specifically, in the validation routine “ValidateTimeStamp()”, the Time portion is correctly compared < 0 but the Date portion is erroneously compared <= 0.

    Consequently a (legitimate) 0.0 Datetime value will sometimes be converted to a Timestamp with datepart = 0, and when this value is again reverse validated (such as when the value is read from a dataset field as shown here and in the QC report), an exception is (erroneously) raised. Hence the simple fix of changing the validation for the Date portion of the timestamp to use strict less-than, fixes the problem exposed by TClientDataset.

    Here’s our workaround, based on Delphi 7.1

    (* SysUtils.pas line 10934 (Delphi 7.1)  *)
    (**)(* fix - Timestamp values 0.0 erroneously designated as invalid *)
    (* D7.1 *)
    (* Walter Prins, originally patched May 2005, submitted 4 June 2009 *)
    procedure ValidateTimeStamp(const TimeStamp: TTimeStamp);
    begin
      if (TimeStamp.Time < 0) or (TimeStamp.Date < 0) then (* Changed TimeStamp.Date <= 0 to TimeStamp.Date < 0 *)
        ConvertErrorFmt(@SInvalidTimeStamp, [TimeStamp.Date, TimeStamp.Time]);
    end;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 127k
  • Answers 127k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer This is what I did instead with a VS Macro… May 12, 2026 at 5:37 am
  • Editorial Team
    Editorial Team added an answer Use of the @Override annotation on methods that are implemented… May 12, 2026 at 5:37 am
  • Editorial Team
    Editorial Team added an answer Another name for this automatic caching of function results is… May 12, 2026 at 5:37 am

Related Questions

I have a problem with a newly installed Visual Studio 2008 (new pc) and
I have created a custom UIView that I would like to use on multiple
How would you test this scenario? I've just started looking into NHibernate and having
I'm trying to build the following block of code in a 1-file .cpp file:

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.