Hi,
I have a Date field and DateTime filed as string variables.

Now i want to customize their formats as like given below.

Ex-1: 20091024
if i specify the seperator as '/' then 2009/10/24
'-' Then 2009-10-24
Ex-2: 200910241011012
if i specify the seperator as '/,:' then 2009/10/24 10:11:12
'-,:' then 2009-10-24 10:11:12

Can any one suggest is there any methods to achive this ??
Thank you very much in advance

Three thoughts. You might look up the ctime header file and see if there is a standard way to do what you want. Otherwise you can develop your own functions to do what you want. I don't think there is anything in iomanip that help you, but you could check there as well.

Thank u very much for the reply,

I have implemented this logic like below.

year=first 4 digits of date string;
month=5,6 digits in date string;
year=7,8 digits in date string;
sprintf(FormattedDate,"%d/%d/%d",year,month,date);

then use finally FormattedDate.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.