Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

mysql and delphi "DateTime"

Posted on 2009-04-05
4
Medium Priority
?
1,942 Views
Last Modified: 2012-05-06
how to convert mySQL datetime (yyyy/mm/dd ss:mm:hhhh) to TDateTime (dd/mm/yyyy ss:mm:hhhh)
0
Comment
Question by:pete_03
  • 3
4 Comments
 
LVL 7

Expert Comment

by:tankergoblin
ID: 24073938
what you want to do
insert datetime to database
or display it on windows?
0
 
LVL 7

Expert Comment

by:tankergoblin
ID: 24073946
you can try

myDate := EncodeDateTime(2000, 6, 5, 1, 2, 3, 4);
FormatDateTime('dd/mm/yyyy ss:mm:hhhh', myDate));
0
 
LVL 19

Accepted Solution

by:
MerijnB earned 200 total points
ID: 24074529
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
 
LVL 7

Expert Comment

by:tankergoblin
ID: 24074766
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

Important Lessons on Recovering from Petya

In their most recent webinar, Skyport Systems explores ways to isolate and protect critical databases to keep the core of your company safe from harm.

Question has a verified solution.

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

A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
The uses clause is one of those things that just tends to grow and grow. Most of the time this is in the main form, as it's from this form that all others are called. If you have a big application (including many forms), the uses clause in the in…
Integration Management Part 2
Is your data getting by on basic protection measures? In today’s climate of debilitating malware and ransomware—like WannaCry—that may not be enough. You need to establish more than basics, like a recovery plan that protects both data and endpoints.…
Suggested Courses

876 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