Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How does one show a date in 'ShowMessage'? 3

Status
Not open for further replies.

delphiman

Programmer
Dec 13, 2001
422
ZA

Could a guru please advise what I need to do to make the following work so that the date (which is 01/07/04) is shown?


ShowMessage('StartDate = ' + tblMyTable.StartDate.value);

Thanks in advance.
 
i dont have delphi in front of me, but from memory its
ShowMessage('StartDate = ' + tblMyTable.FieldByName[StartDate].AsString);

if you double click your table component and add the startdate field to the list then you can do it like this

ShowMessage('StartDate = ' + tblMyTableStartDate.value);

as long as the StartDate field is a string.

Aaron Taylor
John Mutch Electronics
 
This is one way to do it:

Code:
ShowMessage('Today is: ' + DateToStr(Date));

This code show the current date in the message.

Hope this helps,

[bobafett] BobbaFet [bobafett]

Everyone has a right to my opinion.
E-mail me at caswegkamp@hotmail.com
 
Code:
var
  datum: TDate;
  ...
begin
  ...
  datum := tblMyTable.FieldByName('StartDate').AsDateTime;
  ShowMessage ( 'StartDate = ' + FormatDateTime ( 'dd/mm/yy', datum ) );
  ...
end;
This code assumes that your StartDate field is of type TDate and will guarantee that you get the date displayed in dd/mm/yy format as you specified. It is easy enough to change the format string if you want something different.


Andrew
Hampshire, UK
 
or
begin
ShowMessage ( 'StartDate = ' + FormatDateTime ( 'dd/mm/yy', tblMyTable.FieldByName('StartDate').AsDateTime));
end;


Aaron Taylor
John Mutch Electronics
 
Or you could use MessageDlg if you want more control over the look of the message box!

Clive [infinity]
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
"To err is human, but to really foul things up you need a computer."
Paul Ehrlich
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
To get the best answers from this forum see: faq102-5096
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top