Recent

Author Topic: Date-Stamp DBDateEdit  (Read 1201 times)

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 278
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Date-Stamp DBDateEdit
« on: November 29, 2023, 07:52:16 pm »
I have a form for entering/adding data to a client table. One field I need is a date stamp for when the client record was created/added. So, have a field called DateStamp in the table and when the user clicks to add a new client, the current date is updated in a DBDateEdit which is read-only for the user. The problem I have is can't find documentation on all these little components.
I have this working correctly just adding an AfterInsert procedure and just updating the DBDateEdit for the date field in the table with the current date. But, the DBDateEdit defaults to 12/30/1899 before you even attempt to add a record.  The DateFormat isn't documented so that you can store dd mmm. yyyy. But, can live without that, but how do I get rid of this 12/30/1899 showing before you add/insert?

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 278
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Date-Stamp DBDateEdit
« Reply #1 on: November 29, 2023, 08:35:55 pm »
Meant to say display and not store the current date as dd mmm. yyyy

Handoko

  • Hero Member
  • *****
  • Posts: 5377
  • My goal: build my own game engine using Lazarus
Re: Date-Stamp DBDateEdit
« Reply #2 on: November 30, 2023, 03:16:12 am »
Maybe you need to change the default locale setting by using DefaultFormatSettings:
https://wiki.lazarus.freepascal.org/DefaultFormatSettings

1HuntnMan

  • Sr. Member
  • ****
  • Posts: 278
  • From Delphi 7 to Lazarus
    • NewFound Photo Art
Re: Date-Stamp DBDateEdit [SOLVED]
« Reply #3 on: December 02, 2023, 09:01:03 pm »
Thanks friend!  I even have the date displayed now in long format...

cdbc

  • Hero Member
  • *****
  • Posts: 1671
    • http://www.cdbc.dk
Re: Date-Stamp DBDateEdit
« Reply #4 on: December 03, 2023, 08:00:06 am »
Hi
"12/30/1899" represents the value 0 in TDateTime, i.e.: In your formcreate event-handler, set "fDbDateEdit.Value:= now;" to let it show current date...
...and what @Handoko said  ;)
Regards Benny
If it ain't broke, don't fix it ;)
PCLinuxOS(rolling release) 64bit -> KDE5 -> FPC 3.2.2 -> Lazarus 2.2.6 up until Jan 2024 from then on it's: KDE5/QT5 -> FPC 3.3.1 -> Lazarus 3.0

 

TinyPortal © 2005-2018