Solved

mysql and delphi "DateTime"

Posted on 2009-04-05
4
1,792 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 50 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

What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

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…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
This video discusses moving either the default database or any database to a new volume.
In this tutorial you'll learn about bandwidth monitoring with flows and packet sniffing with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're interested in additional methods for monitoring bandwidt…

758 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

Need Help in Real-Time?

Connect with top rated Experts

22 Experts available now in Live!

Get 1:1 Help Now