Solved

date field

Posted on 2002-07-18
15
255 Views
Last Modified: 2010-04-04
I am using a dbedit for a date entry but I always get an error message that the date entered is not a valid date though it is a date. There must be something I need to declare or configure. Can somebody help me on how to handle a date field? Thanks
0
Comment
Question by:sharol
  • 4
  • 4
  • 2
  • +5
15 Comments
 
LVL 27

Accepted Solution

by:
kretzschmar earned 100 total points
ID: 7161676
use the ongettext/onsettext events of the field

in this events use a conversion like

--ongettext
text := Field.AsString;

--onsettext
field.AsDateTime := StrToDate(text);

just from head

meikl ;-)
0
 
LVL 3

Expert Comment

by:LukA_YJK
ID: 7161687
Maybe you actually enter invalid dates. For example you enter '/' as separator, but it is '.' or you enter [month,day,year], but it must be [day,month,year]. To find all these info launch BDE Administrator and look at Configuration-System-Formats-Date. Hope it will be helpful...
0
 

Author Comment

by:sharol
ID: 7164059
Kretzschmar, I cant find the ongettext and onsettext event in the dbedit field. Are you talking anout a TDBEdit component? I cant fine the events you mentioned. Hope you could help me on this.

LukA YJK, I checked the BDE configuration and it is the way you described it to be. Is tehre anything else I can try?
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 27

Expert Comment

by:kretzschmar
ID: 7164073
>Are you talking anout a TDBEdit component?
no, i talk about the underlying tfield

-doubleclick on your dataset-object
-rightclick on the the fieldseditor
-select add all fields
-select your datefield
-assign the events in the object-inspedtor

meikl ;-)
0
 

Author Comment

by:sharol
ID: 7169888
sorry, but Im not very good in Delphi yet(just starting...). how do i assign the event? thanks.
0
 
LVL 4

Expert Comment

by:jsweby
ID: 7172831
Another common cause of the "Invalid Date/Time" error is the fact that you are entering a date in a format different to that set up in your

Control Panel --> Regional Settings --> Date

settings. This specifies the separator and the date format.

J.
0
 

Expert Comment

by:RayNorrish
ID: 7178645
Get the very usefull RXTools from (ex. http://www.torry.net/huge.htm) and drop a TDateEdit on the form.
0
 

Expert Comment

by:RayNorrish
ID: 7178648
I mean a TDBDateEdit :)
0
 

Author Comment

by:sharol
ID: 7183192
How do I use it. Pardon but Im not really good at this yet. Thanks.
0
 

Expert Comment

by:RayNorrish
ID: 7184671
You just need to drop it onto the form, there is no real difference, there is a calendar button with it which can be switched off. It is really very easy to implement.
0
 

Author Comment

by:sharol
ID: 7190079
Sorry again. So, I have downloaded the tool. What do I do next, install it as new component?
0
 

Expert Comment

by:RayNorrish
ID: 7190184
There is a readme.txt that details how to install the package(s).

You must compile the runtime packages for your version of Delphi, and place the bpl files in your search path. Then you must compile and install the design time packages.

If you don't have the install instructions, then look at this example for installing into D5..

1. Delphi 5.x:


Use "File\Open..." menu item of Delphi IDE to open RX' runtime
package RXCTL5.DPK. In "Package..." window click "Compile" button to
compile packages RXCTL5.DPK. After compiling repeat that for other RX
Library run-time packages RXDB5.DPK, RXBDE5.DPK. Put compiled BPL files
into directory that is accessible through the search PATH (i.e. DOS
"PATH" environment variable; for example, in the Windows\System directory).
After compiling RX run-time packages you must install RX design-time
packages into the IDE.

RXCTL5.DPK RXDB5.DPK RXBDE5.DPK
RXCTL5.BPL, RXDB5.BPL, RXBDE5.BPL

Use "File\Open..." menu item to open RX design-time package DCLRX5.DPK.
In "Package..." window click "Compile" button to compile the package
and then click "Install" button to register RX Library components on
the component palette. Repeat that for other RX Library design-time
packages DCLRXDB5.DPK and DCLRXBD5.DPK.
0
 
LVL 2

Expert Comment

by:ferhad
ID: 7211953
Use Simple EditBox (not dbEdit) and type this code:

Table1.FieldByName('Date').AsString:=Edit1.Text;

Time format is Day,Month,Year

Hope it will help
Regards Ferhad
0
 

Expert Comment

by:CleanupPing
ID: 9343039
sharol:
This old question needs to be finalized -- accept an answer, split points, or get a refund.  For information on your options, please click here-> http:/help/closing.jsp#1 
EXPERTS:
Post your closing recommendations!  No comment means you don't care.
0
 
LVL 5

Expert Comment

by:Lukasz Lach
ID: 9461258
sharol,
No comment has been added lately (18 days), so it's time to clean up this TA.
I will leave a recommendation in the Cleanup topic area for this question:

RECOMMENDATION: Award points to kretzschmar http:#7161676

Please leave any comments here within 7 days.

-- Please DO NOT accept this comment as an answer ! --

Thanks,

anAKiN
EE Cleanup Volunteer
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Creating an auto free TStringList The TStringList is a basic and frequently used object in Delphi. On many occasions, you may want to create a temporary list, process some items in the list and be done with the list. In such cases, you have to…
Hello everybody This Article will show you how to validate number with TEdit control, What's the TEdit control? TEdit is a standard Windows edit control on a form, it allows to user to write, read and copy/paste single line of text. Usua…
How to Install VMware Tools in Red Hat Enterprise Linux 6.4 (RHEL 6.4) Step-by-Step Tutorial
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

735 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question