• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 191
  • Last Modified:

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
0
krydea
Asked:
krydea
  • 2
  • 2
  • 2
  • +1
1 Solution
 
geobulCommented:
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
0
 
Mohammed NasmanSoftware DeveloperCommented:
Hi

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

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

Regards,
Mohammed
0
 
mikelittlewoodCommented:
or

StringReplace(DateToStr(date), '-', '/', [rfReplaceAll])
0
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
Mohammed NasmanSoftware DeveloperCommented:
ohh sorry, I didn't notice you would to change the Day/Month

just add

  ShortDateFormat := 'M/d/yyyy';

Regards,
Mohammed
0
 
mikelittlewoodCommented:
bleh  ><  didnt notice that either lol
0
 
geobulCommented:
And I thought krydea was talking about pure string manipulation ;-)
0
 
krydeaAuthor Commented:
sorry
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 2
  • 2
  • 2
  • +1
Tackle projects and never again get stuck behind a technical roadblock.
Join Now