freddyho
asked on
about date & time type
when i retriev the field(date, time) format) from access, delphi also display date&time togeter, but i only want them separately in my program.
use the displayformat-property of the underlying TField
If you want to extract only the Date form DateTime use Trunc, and if you want to use Time form DateTime use Frac. But you can ignore it example:
var
MyDate: TDateTime;
MyTime: TDateTime;
begin
MyDate:= Trunc(Table1.FieldByName(' Reg').AsDa teTime);
MyTime:= Frac(Table1.FieldByName('R eg').AsDat eTime);
ShowMessage(DateToStr(MyDa te));
ShowMessage(TimeToStr(MyTi me));
The same will be fine if you use :
MyDate:= Table1.FieldByName('Reg'). AsDateTime ;
MyTime:= Table1.FieldByName('Reg'). AsDateTime ;
But the case will different if you want to compare two times such as:
if MyTime > YourTime then ...
In this case you muse use Frac to do comparison without Date
Motaz
var
MyDate: TDateTime;
MyTime: TDateTime;
begin
MyDate:= Trunc(Table1.FieldByName('
MyTime:= Frac(Table1.FieldByName('R
ShowMessage(DateToStr(MyDa
ShowMessage(TimeToStr(MyTi
The same will be fine if you use :
MyDate:= Table1.FieldByName('Reg').
MyTime:= Table1.FieldByName('Reg').
But the case will different if you want to compare two times such as:
if MyTime > YourTime then ...
In this case you muse use Frac to do comparison without Date
Motaz
Date
FormatDateTime('mm/dd/yyyy ', Table1.FieldByName('TheFie ld').AsDat eTime);
Time
FormatDateTime('hh:nn:ss', Table1.FieldByName('TheFie ld').AsDat eTime);
In the first paramater you is how it will be displayed. You can arrange to display in any manner you want it to.
FormatDateTime('mm/dd/yyyy
Time
FormatDateTime('hh:nn:ss',
In the first paramater you is how it will be displayed. You can arrange to display in any manner you want it to.
Or use
Table1.FieldByName('TheFie ld').AsDat e
and
Table1.FieldByName('TheFie ld').AsTim e
for any further handling of dates & times...
Table1.FieldByName('TheFie
and
Table1.FieldByName('TheFie
for any further handling of dates & times...
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Greetings.
This question is still open today, perhaps it was overlooked or just lost in the volumes. Please return to this question to update it with comments if more information is needed to get your solution. If you've been helped by the participating expert(s), you may just convert their comment to the accepted answer and then grade and close. If an answer has ever been proposed you may not have this option to accept the comment as answer, if that is the case, ask the specific expert you wish to award to post an answer. This benefits others who then search our PAQ for just this solution, and rewards the experts who have provided information. A win/win scenario. Please DO NOT accept this comment as an answer, it is merely a reminder.
If you wish to award multiple participants, you can do so by creating a zero point question in the Community Support topic area, include this link and tell them which experts you'd like to award what amounts. If you'd like to delete this question, use the same process as above, but explain why you think it should be deleted. Here is the Community Support link: https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
You can always click on your profile to see all your open questions, in the event you also have other open items to be resolved. If your number of Questions Asked is not equal to the number of Answers Graded, choose to VIEW question history, and you'll quickly be able to navigate to your open items to close them as well.
I've had excellent help from experts-exchange through the years and find the real key to getting what I need is to remain active in all my questions, responding with results to suggestions until my solution is found, and recommend that highly.
Thank you very much for your responsiveness, it is very much appreciated.
":0) Asta
P.S. Some of the older questions from last year are not in the proper comment date order, and Engineering has been advised.
This question is still open today, perhaps it was overlooked or just lost in the volumes. Please return to this question to update it with comments if more information is needed to get your solution. If you've been helped by the participating expert(s), you may just convert their comment to the accepted answer and then grade and close. If an answer has ever been proposed you may not have this option to accept the comment as answer, if that is the case, ask the specific expert you wish to award to post an answer. This benefits others who then search our PAQ for just this solution, and rewards the experts who have provided information. A win/win scenario. Please DO NOT accept this comment as an answer, it is merely a reminder.
If you wish to award multiple participants, you can do so by creating a zero point question in the Community Support topic area, include this link and tell them which experts you'd like to award what amounts. If you'd like to delete this question, use the same process as above, but explain why you think it should be deleted. Here is the Community Support link: https://www.experts-exchange.com/jsp/qList.jsp?ta=commspt
You can always click on your profile to see all your open questions, in the event you also have other open items to be resolved. If your number of Questions Asked is not equal to the number of Answers Graded, choose to VIEW question history, and you'll quickly be able to navigate to your open items to close them as well.
I've had excellent help from experts-exchange through the years and find the real key to getting what I need is to remain active in all my questions, responding with results to suggestions until my solution is found, and recommend that highly.
Thank you very much for your responsiveness, it is very much appreciated.
":0) Asta
P.S. Some of the older questions from last year are not in the proper comment date order, and Engineering has been advised.
SECOND REQUEST.
hi
i will be asking community support to close this question in 7 days.
i will be requesting that the points are split evenly for each commenter (except astaec and myself of course) .
Regards Barry
DO NOT ACCEPT THIS COMMENT AS ANSWER
hi
i will be asking community support to close this question in 7 days.
i will be requesting that the points are split evenly for each commenter (except astaec and myself of course) .
Regards Barry
DO NOT ACCEPT THIS COMMENT AS ANSWER
A five-way split? On a fifty-point question?! Who's been talking to COBOLdinosaur?!?!
Per recommendation comment force/accepted by
Netminder
Community Support Moderator
Experts Exchange
kretzschmar: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20277945
Workshop_Alex: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20277953
CrazyOne: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20277955
Motaz: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20277957
Per recommendation comment force/accepted by
Netminder
Community Support Moderator
Experts Exchange
kretzschmar: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20277945
Workshop_Alex: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20277953
CrazyOne: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20277955
Motaz: points for you at https://www.experts-exchange.com/jsp/qShow.jsp?ta=delphi&qid=20277957
<G>