----- Original Message -----
From: "soonhuat ong" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Monday, April 04, 2005 4:14 AM
Subject: [list] [delphi-en] Date formatting
>
>
> Hi,
>
> I've got the datetime value of 1/31/2005, and now i would like to change
> it to 31/01/2005.. Is there any date formating function available like
> what we have in C# etc. Thanks
Lots of stuff that a simple search in the Delphi help would turn up ("Help"
menu -> "Delphi Help"->"Find" tab, and search for (for example) "date
formatting" . )
Anyway, here's an example of how you might do what you want:
procedure TForm1.Button1Click(Sender: TObject);
var
FormatSettings : TFormatSettings;
begin
// populate format settings object with defaults
GetLocaleFormatSettings( GetUserDefaultLCID, FormatSettings );
// change to input format to be converted to date
FormatSettings.ShortDateFormat := 'MM/dd/yyyy';
// Convert '1/31/2005' to Date using correct format, then format back to
string in format 'dd/mm/yyyy'
Label1.Caption := FormatDateTime('dd/mm/yyyy', StrToDate('1/31/2005',
FormatSettings));
end;
Cheers
Walter Prins
-----------------------------------------------------
Home page: http://groups.yahoo.com/group/delphi-en/
To unsubscribe: [EMAIL PROTECTED]
Yahoo! Groups Links
<*> To visit your group on the web, go to:
http://groups.yahoo.com/group/delphi-en/
<*> To unsubscribe from this group, send an email to:
[EMAIL PROTECTED]
<*> Your use of Yahoo! Groups is subject to:
http://docs.yahoo.com/info/terms/