Link to home
Start Free TrialLog in
Avatar of krydea
krydea

asked on

string edit replace - with /

hello,
i'm loading a date from an db file and i whant to change it from 12-01-2004 to 01/12/2004  
can someone tell me how to do this basic thing???

thanx greetz carlas
Avatar of geobul
geobul

Hi,

function DateStringFormat(const d: string): string;
begin
  result := Copy(d,4,2)+'/'+Copy(d,1,2)+'/'+Copy(d,7,4);
end;

// usage:

ShowMessage(DateStringFormat('12-01-2004'));

Regards, Geo
Avatar of Mohammed Nasman
Hi

Change the  "DateSeparator" global variable to any format you like as:

  DateSeparator := '/';
  ShowMessage(DateToStr(Date));

Regards,
Mohammed
or

StringReplace(DateToStr(date), '-', '/', [rfReplaceAll])
ASKER CERTIFIED SOLUTION
Avatar of Mohammed Nasman
Mohammed Nasman
Flag of Palestine, State of image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
bleh  ><  didnt notice that either lol
And I thought krydea was talking about pure string manipulation ;-)
Avatar of krydea

ASKER

sorry