![]() |
|
#1
|
|||
|
|||
Custom String FormattingHi All,
I'm using c++.net and have a string that represents a date. "122804"(mmddyy) Any ideas on using DateTimeFormatInfo to take that value and make it: "20041228" (yyyymmdd) or if not possible: "041228"(yymmdd) Any help would be great. Thanks a lot, Todd |
|
#2
|
||||
|
||||
|
You'll have to split and recombine it yourself. A simple function would do it.
__________________
Got a cough? Go home tonight and eat a whole box of Ex-Lax. Tomorrow, you'll be afraid to cough. -- Pearl Williams |
|
#3
|
|||
|
|||
|
Quote:
Cool I figured as much. Thanks, Todd |
|
#4
|
||||
|
||||
|
Hi, Todd.
I'm sorry I overlooked this thread. I meant to post an answer, but the notification message got lost in the mess called my mail account From what I understood, you are looking for a solution based on the .NET Framework. However, this was the wrong forum to post your thread. You should have posted in the .NET Forum, and I'm sure you would have gotten a solution earlier. Walt gave you a solution based on what you required by posting here. Simply stating that you use vc.net does not imply that you are using managed code. Please don't take this the wrong way; I'm simply explaining the answer you got. In fact, you have the possibility to accomplish what you required by means of the DateTimeFormatInfo class. Actually, you can do it without making use of it at all. If you would have the date in the DateTime format, I think you agree that this is pretty simple: CPP / C++ / C Code:
So, the trick would be to transform your string into that. That's not so difficult either: CPP / C++ / C Code:
In case this was not what you required and my understanding of your post was flawed, please correct me. Also, I'm sorry if my answer arrived to late for you to make use of it. In case you confirm that you were looking for a solution that makes use of the .NET Framework, I will move this thread to the appropriate forum. Kind regards, Lucian __________________
Please read these Guidelines before posting on the forum "A person who never made a mistake never tried anything new." Einstein |
|
#5
|
|||
|
|||
|
Lucian,
I really appreciate your response. I looked at that class and ended up deciding that a simple string format would work in a lot less code. If the string dates I was getting were valid date formats then I might be tempted to go the route you mention but they're not. I'd have to do string formatting on my inputs JUST to begin to use the code you mention. Again, I appreciate your response a lot and you've cleared up some questions I still had regarding the CultureInfo class. Thanks again, Todd |
Recent GIDBlog
US Elections and the ?Voter?s Responsibility? by crystalattice
| Thread Tools | Search this Thread |
| Rate This Thread | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Read a .html file, check that file for links | salemite | C Programming Language | 10 | 17-Jan-2008 08:56 |
| Re: Conversion: Binary, Decimal, Hexadecimal | WaltP | C Programming Language | 1 | 10-May-2006 07:49 |
| C++ string from file | small_ticket | C++ Forum | 3 | 05-Jan-2005 08:29 |
| storing a token pointer as a string | CoreLEx | C Programming Language | 1 | 07-Oct-2003 12:33 |
Network Sites: GIDNetwork · GIDWebHosts · GIDSearch · Learning Journal by J de Silva, The