Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

I Want : Label1.Caption := DateToStr(Date); like this 12-10-1999 how do i do this in delphi 4 The help does not seem right

65 views
Skip to first unread message

Vrijwillige Bloemendaalse Reddingsbrigade

unread,
Jan 1, 1999, 3:00:00 AM1/1/99
to
I Want : Label1.Caption := DateToStr(Date); like this 12-10-1999
how do i do this in delphi 4 The help does not seem right

E. Abel

unread,
Jan 1, 1999, 3:00:00 AM1/1/99
to
You could use the DecodeDate function to place the Month Day and Year into
variables and then piece them together to form the string you require.

Here is a snip from the DecodeDate, DecodeTime help file example
procedure TForm1.Button1Click(Sender: TObject);
var
Present: TDateTime;
Year, Month, Day, Hour, Min, Sec, MSec: Word;
begin
Present:= Now;
DecodeDate(Present, Year, Month, Day);
Label1.Caption := 'Today is Day ' + IntToStr(Day) + ' of Month '
+ IntToStr(Month) + ' of Year ' + IntToStr(Year);
DecodeTime(Present, Hour, Min, Sec, MSec);
Label2.Caption := 'The time is Minute ' + IntToStr(Min) + ' of Hour '
+ IntToStr(Hour);
end;


Vrijwillige Bloemendaalse Reddingsbrigade wrote in message
<76j6ie$g55$1...@news.news-service.com>...

Sergey Tavanets

unread,
Jan 1, 1999, 3:00:00 AM1/1/99
to
Hi!
You may use FormatDateTime function:

Label1.Caption := FormatDateTime(mask, date)

where mask is format mask for data representation (it's quite flexible and
you're
not bounded to one particular format) and date is value of TDateTime type.
See help on this function for further details.

Hope it helps.

Regards,

Sergey.

Vrijwillige Bloemendaalse Reddingsbrigade <In...@vbr.vuurwerk.nl> wrote in
message 76j6ie$g55$1...@news.news-service.com...

Glatzfamly

unread,
Jan 2, 1999, 3:00:00 AM1/2/99
to
Try this:

label1.Caption := FormatDateTime('MM-DD-YYYY',Date);

********************************
Michael Glatz
glatz...@aol.com
mgl...@briefcase.com

FASTOCHE

unread,
Jan 2, 1999, 3:00:00 AM1/2/99
to
Label1.Caption :=FormatDateTime('MM-DD-YYYY',Date)

Yours

Didier, PARIS, France

Markku Nevalainen

unread,
Jan 2, 1999, 3:00:00 AM1/2/99
to
Vrijwillige Bloemendaalse Reddingsbrigade wrote:
>
> I Want : Label1.Caption := DateToStr(Date); like this 12-10-1999
> how do i do this in delphi 4 The help does not seem right


Hw 'bout: Label1.Caption:=FormatDateTime('mm-dd-yyyy', Date);

Russell Anscomb

unread,
Jan 2, 1999, 3:00:00 AM1/2/99
to
In article <368EBE...@dial.pipex.com>, Nick Gabb
<hm...@dial.pipex.com> writes

>Vrijwillige Bloemendaalse Reddingsbrigade wrote:
>>
>> I Want : Label1.Caption := DateToStr(Date); like this 12-10-1999
>> how do i do this in delphi 4 The help does not seem right
>Search DateSeparator or ShortDateFormat in the help
>this is the example for 12-10-1999
>
>procedure TForm1.Button1Click(Sender: TObject);
>
>begin
> DateOrder := doDMY;
> DateSeparator := '-';
> DateFullYear := True;
> DateLeadZero := True;
> Label1.Caption := DateToStr(Date);
>end;
>
>Nick

It's easier to use FormatDateTime:

Label1.Caption := FormatDateTime('dd-mm-yyyy', Date);

--
Russell Anscomb

Nick Gabb

unread,
Jan 3, 1999, 3:00:00 AM1/3/99
to
0 new messages