Click to See Complete Forum and Search --> : Custom String DateFormating in VC++.Net


rm_kapadia
July 18th, 2005, 10:33 AM
Hi All,

I'm using vc++.net and have a string that represents a date.

"122804"(mmddyy)

Any ideas on using DateTimeFormatInfo to take that value and make it: ( or How to write a Custom parser class for this numeric Data )

"20041228" (yyyymmdd)

or if not possible:

"041228"(yymmdd)

Any help would be great.

Thanks in Advance ...

Rajan Kapadia

GCDEF
July 18th, 2005, 11:13 AM
You could do it with CStrings.


CString strMDY = "122804";
CString strYMD;
strYMD.Format("20%s%s", strMDY.Right(2), strMDY.Left(4));

rm_kapadia
July 19th, 2005, 02:00 AM
Thanks for u r Reply .....
But at Runtime I only know what is come as a text for my Date!!!

various possibility are :

mmddyyyy

mdyyyy
mmdyyyy
mddyyyy

mmdy
mddy
mdyy

mddyy
mmdyy
mmddy

mmddyy

mdy
mmd
ddm

I m Confused due to ambiguation for this text( here ... Numerics) comes as a 6,5,4,3 digits .... (i.e.: for 5digits --> mddyy,mmdyy,mmddyy) how to handle these situations ....... I m to'much Confuseed !......!

can any one help me for this soluation??

thanks in advance!!

Rajan Kapadia

Andy Tacker
July 19th, 2005, 05:41 AM
moved to VC.NET forum.


Datatime class has function ToString()... where you can specify the format you want to see...

Dateime.Now.ToString("yyyy-MM-dd HH:mm:ss")

rm_kapadia
July 19th, 2005, 08:27 AM
moved to VC.NET forum.


Datatime class has function ToString()... where you can specify the format you want to see...

Dateime.Now.ToString("yyyy-MM-dd HH:mm:ss")


Thanks for reply... but ,, I have mantion clearly how I can Dis-ambiguates between possiblty of the same string divde in to same but diffrent parts....
i.e: for 5digits --> mddyy,mmdyy,mmddyy How to handle this ???

other Varios possibility are :
mmddyyyy ( 8 digit max)

mdyyyy
mmdyyyy
mddyyyy

mmdy
mddy
mdyy

mddyy
mmdyy
mmddy

mmddyy

mdy
mmd
ddm ( 3 digit min)

I m Confused due to ambiguation for this text( here ... Numerics) comes as a 6,5,4,3 digits .... (i.e.: for 5digits --> mddyy,mmdyy,mmddyy) how to handle these situations ....... I m to'much Confuseed !......!