Login ProductsSalesSupportDownloadsAbout |
Home » Technical Support » DBISAM Technical Support » Support Forums » DBISAM General » View Thread |
Messages 1 to 4 of 4 total |
Empty date 1899 |
Wed, Nov 26 2008 3:23 AM | Permanent Link |
"Carlos" | DBISAM Ver. 3.30
Hello to all Sometimes I have to copy a DateTime from a table to another. For this use the following statement: DB1.FieldByName ( 'MYDATE'). AsDateTime: = DB2.FieldByName ( 'MYDATE'_1'). AsDateTime; Everything is fine, but if by chance the date of DB2 is empty, the DB1.'MYDATE' date field is saved as 1899 !!! Whenever I am forced to do the following if not DB2.FieldByName ( 'MYDATE'). IsNull then begin ... end; It can avoid whenever do this "if"? Thank you Carlos |
Wed, Nov 26 2008 4:54 AM | Permanent Link |
Mauricio Campana Nonino | Carlos,
Try: DB1.FieldByName ( 'MYDATE'). Value: = DB2.FieldByName ( 'MYDATE'_1'). Value; Mauricio Campana Nonino Nonino Software |
Wed, Nov 26 2008 3:26 PM | Permanent Link |
Sean | Carlos,
In addition to copying by TField.Value (a Variant), you can also use: DB1.FieldByName ( 'MYDATE').Assign(DB2.FieldByName ( 'MYDATE'_1')) As you've probably realized by now, copying by using TField.AsInteger/Date/etc casts the field value to the requested type (Integer, Date, etc) and so Null values get translated. Numerics go to zero, strings go to empty, booleans to False. Date is really a floating point , so you get Dec 31, 1899 which is the value represented by 0. Hope this helped, Sean Carlos wrote: > DBISAM Ver. 3.30 > > Hello to all > Sometimes I have to copy a DateTime from a table to another. > For this use the following statement: > > DB1.FieldByName ( 'MYDATE'). AsDateTime: = DB2.FieldByName ( 'MYDATE'_1'). > AsDateTime; > > Everything is fine, but if by chance the date of DB2 is empty, the > DB1.'MYDATE' date field is saved as 1899 !!! > > Whenever I am forced to do the following > > if not DB2.FieldByName ( 'MYDATE'). IsNull then begin ... end; > > It can avoid whenever do this "if"? > > Thank you > > Carlos > > |
Thu, Nov 27 2008 3:49 AM | Permanent Link |
"Carlos" | thanks!
Carlos |
This web page was last updated on Friday, September 20, 2024 at 05:39 PM | Privacy PolicySite Map © 2024 Elevate Software, Inc. All Rights Reserved Questions or comments ? E-mail us at info@elevatesoft.com |