[SOLVED] TDateTimePicker problem lazarus / 31-LCL ---------------------------------------------------------------------- dseligo · 2021-12-28 08:45 When I set Date property to 'null' in Object inspector (either by pressing 'N' in Datetimepicker editor or by simply entering 'null') I get error 'Error reading DateTimePicker1.Date: Floating point overflow' when form is created in program. If I set date property to 'null' programatically with DateTimePicker1.Date := NullDate; then it works. Reproduction: put DateTimePicker on form, set Date property to 'null', run the program. I have Lazarus 2.0.10, FPC 3.2.0, Windows 11. Target OS is Win32, target CPU family is 386. ---------------------------------------------------------------------- winni · 2021-12-28 08:59 Hi! No problems here. Laz 2.0.12 fpc 3.2 Linux64 Winni ---------------------------------------------------------------------- dseligo · 2021-12-28 09:00 When I compile it for target Win64, target CPU family x86_64 results are different, there is no error, but it also doesn't work as supposed to. If Date property is set to 'null' in Object inspector then value shown in DateTimePicker is '30.12.1899'. If Date property is set programatically with DateTimePicker1.Date := NullDate; then value shown is 'NULL' (so, it works). Property TextForNullDate is 'NULL' (default value). ---------------------------------------------------------------------- AlexTP · 2021-12-28 09:12 You cannot set the property Date to 'NULL' or another string - its type is TDate in the code. Type of Time propety is TTime. (Maybe Obj Inspector supports this as a feature?) ---------------------------------------------------------------------- dseligo · 2021-12-28 09:22 Quote from: Alextp on December 28, 2021, 10:12:09 amYou cannot set the property Date to 'NULL' or another string - its type is TDate in the code. Type of Time propety is TTime. (Maybe Obj Inspector supports this as a feature?) Yes, you can: https://wiki.freepascal.org/DateTimeCtrls_Package#NullIn putAllowed:_Boolean ---------------------------------------------------------------------- winni · 2021-12-28 09:27 Quote from: Alextp on December 28, 2021, 10:12:09 amYou cannot set the property Date to 'NULL' or another string - its type is TDate in the code. Type of Time propety is TTime. (Maybe Obj Inspector supports this as a feature?) Hi That is wrong. Nulldate is defined by the TDateTimePicker and you can enter "N" in the dialog for the date. From the TDateTimePicker: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i const  { We will deal with the NullDate value the special way. It will be especially    useful for dealing with null values from database. }  NullDate = TDateTime(Math.MaxDouble); Winni ---------------------------------------------------------------------- dseligo · 2021-12-29 03:24 Update: I tried Lazarus 2.0.10 on another computer with Windows 10 and it has a same problem. Tried 2.0.12 on Windows 11, same problem. With 2.0.8, FPC 3.0.4 on Windows 10 is fine (no problem). With trunk 2.3.0 it's fine and with Lazarus 2.2.0 RC2, FPC 3.2.2 too. I think I'll just use code to set 'null' in OnCreate event for now (until 2.2.0 will be released). ---------------------------------------------------------------------- Zoran · 2021-12-29 10:25 Yes, I experienced this couple of months ago. This problem appears sometimes when loading this value from stream and only after Math.MaxDouble declaration was changed (fpc 3.2). In FPC 3.0.4 (unit math) it was declared as:   MaxDouble    =  1.7e+308; In FPC 3.2 it is:   MaxDouble    =  1.7976931348623157e+308; After that, I changed the declaration of NullDate. In Lazarus trunk it is no more declared as Math.MaxDouble, but explicitely:   NullDate = TDateTime(1.7e+308); With this change, the problem disappeared. So, update Lazarus to trunk or, as a workaround, change the NullDate declaration yourself (datetimepicker.pas, line 55). ---------------------------------------------------------------------- Zoran · 2021-12-29 11:22 Time flies, it was actually changed in may 2020. See: https://gitlab.com/freepascal.org/lazarus/lazarus/- /commit/6e4dbe9fd0e751052819a95de8bdc68b0474a53f The comment says:QuoteDateTimePicker: change declaration of NullDate - Math.MaxDouble declaration changed in fpc 3.2, and in some corner cases can make problems (mantis #37087). So, we'll just keep using 1.7e+308 (which was Math.MaxDouble in fpc 3.0.4). ---------------------------------------------------------------------- dseligo · 2021-12-29 11:31 Quote from: Zoran on December 29, 2021, 11:25:08 amYes, I experienced this couple of months ago. This problem appears sometimes when loading this value from stream and only after Math.MaxDouble declaration was changed (fpc 3.2). In FPC 3.0.4 (unit math) it was declared as:   MaxDouble    =  1.7e+308; In FPC 3.2 it is:   MaxDouble    =  1.7976931348623157e+308; After that, I changed the declaration of NullDate. In Lazarus trunk it is no more declared as Math.MaxDouble, but explicitely:   NullDate = TDateTime(1.7e+308); With this change, the problem disappeared. So, update Lazarus to trunk or, as a workaround, change the NullDate declaration yourself (datetimepicker.pas, line 55). Thank you for explanation. ---------------------------------------------------------------------- Zoran · 2021-12-29 11:42 Quote from: dseligo on December 29, 2021, 12:31:18 pmThank you for explanation. You are welcome. This change is included in Lazarus 2.2, which is about to be released. So, you do not need trunk actually, you can take Lazarus 2.2 rc3. ---------------------------------------------------------------------- Zoran · 2021-12-29 12:00 Quote from: Alextp on December 28, 2021, 10:12:09 amYou cannot set the property Date to 'NULL' or another string - its type is TDate in the code. Type of Time propety is TTime. (Maybe Obj Inspector supports this as a feature?) Object inspector supports it because there is a special property editor for it -- you can search for TDateTimePickerDateTimePropEditor class in unit DateTimePickerPropEdit, which is in DateTimeCtrlsDesign package.