On Tue, 2006-06-06 at 23:10 +0200, Graeme Geldenhuys wrote:
> On 6/6/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> > > has a value of 0. This will occur both in the Designer and in execution.
> > > Sometimes the string of numbers varies some.
> >
> > SQL Date and Time fields, in most SQL Servers, cannot have a 0 value like
> > integers or "" (empty string) for characters.
> >
> > Actually, M$ have added 2 new data types to its SQL Server cause of this:
> > "ElapsedTime" and "Elapsed Date", that supoort an empty value.
> >
> > If your fields have a 0 value because they're corrupted, you must have
> > either assign a NULL state (or NULL value) to them, or assign a valid date
> > like when the database/table was created.
> >
> > If you still want to assign a empty value, you could either use a NULL
> > value, or change you field data type to integer and use your own functions
> > to convert from and to date...
> 
> Or do what we did at our company after fighting for ages with
> different RDMS handling dates differently, not to mention 3rd party
> tools accessing the databases as well.  We standardized on the
> International ISO 8601 date time format and use a string field to
> store the value.
> http://www.cl.cam.ac.uk/~mgk25/iso-time.html
> 
> For storage we use:  yyyymmddThhmmss   eg:  20060606T230300
> For display we use:   yyyy-mm-dd hh:mm:ss   eg:  2006-06-06 23:03:00
> 
> A empty date or time is simply stored using zeros.
> We even wrote a few routines doing the different conversions from
> TDateTime to String or other way round (with lots of unit tests of
> course!)
> 
> My 2 cents worth...  :-)

Well, as long as it's Delphi/FPC/MS Acces or something...

I should use a TDateTime, which is a float.

Create the DB-fields as float's, store a TDateTime in it, and you're
done. Works on all databases and has support for '0'.

It's the same trick as you used, but you don't need to think of a
localisation-format and you don't need any special conversion-units...

Joost




_________________________________________________________________
     To unsubscribe: mail [EMAIL PROTECTED] with
                "unsubscribe" as the Subject
   archives at http://www.lazarus.freepascal.org/mailarchives

Reply via email to