mysql and delphi "DateTime"

how to convert mySQL datetime (yyyy/mm/dd ss:mm:hhhh) to TDateTime (dd/mm/yyyy ss:mm:hhhh)
pete_03Asked:
Who is Participating?
 
MerijnBSr. Software EngineerCommented:
Is this field defined as a datetime in the mysql database?
If yes, just go:

var DataSet: TDataSet;
    DateTime: TDateTime;
begin
 DateTime := DataSet.FieldByName('MyDateField').AsDateTime;
end;

Open in new window

0
 
tankergoblinCommented:
what you want to do
insert datetime to database
or display it on windows?
0
 
tankergoblinCommented:
you can try

myDate := EncodeDateTime(2000, 6, 5, 1, 2, 3, 4);
FormatDateTime('dd/mm/yyyy ss:mm:hhhh', myDate));
0
 
tankergoblinCommented:
if you want to select from query you can do as follow


FHolidayDates := TStringList.Create;
FHolidayDates.Add(FormatDateTime('dd/mm/yyyy ss:mm:hhhh', FieldByName('columnName').AsDateTime));
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.