Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Read From a File and Put in a DataBase with DateTime Field

Status
Not open for further replies.

luistsousa

Technical User
May 12, 2003
66
PT
Hello everybody

I intended to read from a file txt and to put this information in a Table. However, in the database, I have a DateTime field, and others two to integer.

How I can read from this file and at the same time, to convert this information for the database?

file example:
25-07-2003 18:27:08 34 54
25-07-2003 18:27:40 76 87


Best Regards
Luis
 
If you put your date into a string, then replace the dashes with slashes, then put the string into a TDateTime, you should be able to carry on.
[blue]
Code:
procedure TForm1.Button1Click(Sender: TObject);
var
  s1,s2:string;
  dt:TDateTime;
begin
  s1 := '25-07-2003 18:27:08';
  s1 := StringReplace( s1, '-', '/', [rfReplaceAll] );
  dt := StrToDateTime( s1 );
  ShowMessage( DateTimeToStr( dt ));
end;
[/color]


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top