Forum > LCL

[SOLVED] TDBDateTimePicker???

(1/3) > >>

1HuntnMan:
I am attempting to use DBDateTimePicker on an Appointments form.  I set up the form and testing, all okay except the TDBDateTimePicker.  What's with the Time, it defaults to 12:00 AM. You can change the date and time but when you post/save the time part goes back to 12:00 AM.  Is there a property that I'm not setting correctly?

Zoran:
You must do better than this if you expect help.
You didn't say anything about your environment. Not even which database system you are using!
Read: https://wiki.freepascal.org/Forum

Works well here - Lazarus 3.1 fixes branch, SQLDb, FPC 3.2.2, Firebird 3, Windows 10.

Check your field data type - is it date or datetime (called timestamp in Firebird)?

If there is someone with a better crystal ball model than mine...

wp:
Yes, big crystal ball needed here... But I guess he is declaring the field type as ftDate (which removes the fractional part of the date/time numbers) and uses the DBDateTimePicker with property Kind = dtkDateTime to display both date and time (but the time part has been removed by the field type ftDate).

Solution: declare the field type as ftDateTime when you want both data and time.

Zvoni:
And going by his other threads in the Database-Section, i'd hazard a guess, it's DBase....

1HuntnMan:
It's not a multi-user system, it's a photography application I'm writing for a fellow photographer. So, I am using TDbf/Datasets, Level 7.  When I designed the Appointments table, I used My Dbf Studio to setup the table and the rest of the tables.  I added the APPTDTIME field as Date/Time with an index. But, checking awhile ago with My Dbf Studio, the field is just designed as Date.  I thought I set it to Date/Time and not just Date.  So, changed it to Date/Time, deleted the index and recreated it and restructured the table.  Then, went back to check and My Dbf Studio is NOT saving as Date/Time it's reverting to just Date.  Deleted the Index and went back 3 times and changed the field type to Date/Time and restructured the table. But, My Dbf Studio isn't saving as Date/Time no matter how many times I change it back to field type Date/Time.

I also put in a Setup menu option with a procedure to create the whole Database (tables and indexes). Here's the code for the Appointments table.  I'm going to run this and recreate just the Appointments table and indexes. Then test again and see if that fixes the issue. My Dbf Studio isn't working right on this issue.  If this fixes the issue, then I'll check to see if there's an update to My Dbf Studio.

Code for creating the Appointments table and indexes:

--- Code: Pascal  [+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i < x.length; i++) { x[i].style.maxHeight='none'; x[i].style.height = Math.min(x[i].clientHeight+15,306)+'px'; x[i].style.resize = "vertical";}};} ---  SpdBtnPMSDataRebuild.Enabled:= False;  PrgrsBarTableRebld.Position:= 5;  ForceDirectories('PMS Data'); { Note: PMS Database Directory = PMS Data }  if FileExists('Appointments.dbf') then    DeleteFile('Appointments.dbf');  Appointments := TDbf.Create(nil);  try     // ForceDirectories('PMS Data');     { Use the relative path to the "PMS Data" directory }     Appointments.FilePath := 'PMS Data' + DirectorySeparator;     { Use Visual dBase VII compatible tables for Lazarus }     Appointments.TableLevel:= 7;     Appointments.Exclusive:= True;     Appointments.TableName:= 'Appointments.dbf';     with Appointments.FieldDefs do begin       PrgrsBarTableRebld.Step:= 10;       PrgrsBarTableRebld.Position:= 10;       Add('APPTID', ftAutoInc, 4, True);       Add('APPTDATETIME', ftDateTime, 8, True); // Do I leave the field length empty here???       Add('CNTKLNAME', ftString, 15, True);       Add('CNTKFNAME', ftString, 15, True);       Add('CNTKMI', ftString, 1, True);       Add('CLIENT', ftString, 25, True);       Add('PHONE', ftString, 15, True);       Add('EMAIL', ftString, 25, True);       Add('ADDRESS', ftString, 30, True);       Add('CITY', ftString, 25, True);       Add('STATEPROV', ftString, 2, True);       Add('POSTALCODE', ftString, 10, True);       Add('DIRECTIONS', ftMemo, 10, True);       Add('NOTES', ftMemo, 10, True)     end;     Appointments.CreateTable;     Appointments.Open;     PrgrsBarTableRebld.Position:= 30;     {Add the primary index}     Appointments.AddIndex('APPTNO','APPTID',[ixPrimary]);     {Add a secondary indexes}     Appointments.AddIndex('APPTDTIME','DTOS(APPTDATETIME)',[]);     Appointments.AddIndex('CNTKNAME','CNTKLNAME+CNTKFNAME+CNTKMI',       [ixExpression, ixCaseInsensitive]);     Appointments.AddIndex('CLIENT','CLIENT',[ixCaseInsensitive]);     Appointments.Close;   finally     Appointments.Free;   end; 

Navigation

[0] Message Index

[#] Next page

Go to full version