[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1988
  • Last Modified:

mysql and delphi "DateTime"

how to convert mySQL datetime (yyyy/mm/dd ss:mm:hhhh) to TDateTime (dd/mm/yyyy ss:mm:hhhh)
0
pete_03
Asked:
pete_03
  • 3
1 Solution
 
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
 
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:
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now