473,513 Members | 2,676 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

string.Format() help

Hi i have a string like "22/5/2006 12:00:00 p" and i want to create
a string like "05/22/06"
could someone please

Jun 2 '06 #1
7 1767
Take a look at DateTime.Parse and DateTime.ParseExact. Once you have a valid
DateTime object you can use its ToString method to format the output

/claes

"tolisss" <ap****************@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
Hi i have a string like "22/5/2006 12:00:00 p" and i want to create
a string like "05/22/06"
could someone please
Jun 2 '06 #2
Try:
System.DateTime MyTime = System.DateTime.Now;

System.Console.WriteLine(MyTime.ToString("HH:mm:ss "));

Alain
"tolisss" <ap****************@gmail.com> a crit dans le message de news:
11**********************@f6g2000cwb.googlegroups.c om...
Hi i have a string like "22/5/2006 12:00:00 p" and i want to create
a string like "05/22/06"
could someone please
Jun 2 '06 #3
Hope this is detail enough for you:
http://msdn.microsoft.com/library/de...SV01077681.asp

chanmm

"tolisss" <ap****************@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
Hi i have a string like "22/5/2006 12:00:00 p" and i want to create
a string like "05/22/06"
could someone please
Jun 2 '06 #4
supose i want a more generic method
suppose i do not know what type the format string is going to produce
is there a more generic format method? can;t use DateTime.Parse method
i want somethong like Type.Parse

Ο/Η Claes Bergefall *γραψε:
Take a look at DateTime.Parse and DateTime.ParseExact. Once you have a valid
DateTime object you can use its ToString method to format the output

/claes

"tolisss" <ap****************@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
Hi i have a string like "22/5/2006 12:00:00 pµ" and i want to create
a string like "05/22/06"
could someone please


Jun 5 '06 #5
If you wan't to parse any data type, then you have to be a bit more
specific about what kind of data you can expect, and how that should be
interpreted.

tolisss wrote:
supose i want a more generic method
suppose i do not know what type the format string is going to produce
is there a more generic format method? can;t use DateTime.Parse method
i want somethong like Type.Parse

Ο/Η Claes Bergefall *γραψε:
Take a look at DateTime.Parse and DateTime.ParseExact. Once you have a valid
DateTime object you can use its ToString method to format the output

/claes

"tolisss" <ap****************@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
Hi i have a string like "22/5/2006 12:00:00 pµ" and i want to create
a string like "05/22/06"
could someone please

Jun 5 '06 #6
let me be a little more specific then i have this proerpty called
formatstring and a user can put in design mode any format string he
wants and the type representation.

but code doesn't know the type so to use the appropriate method

does that make any sense to u? how to procceed
Ο/Η Göran Andersson *γραψε:
If you wan't to parse any data type, then you have to be a bit more
specific about what kind of data you can expect, and how that should be
interpreted.

tolisss wrote:
supose i want a more generic method
suppose i do not know what type the format string is going to produce
is there a more generic format method? can;t use DateTime.Parse method
i want somethong like Type.Parse

Ο/Η Claes Bergefall *γραψε:
Take a look at DateTime.Parse and DateTime.ParseExact. Once you have avalid
DateTime object you can use its ToString method to format the output

/claes

"tolisss" <ap****************@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
Hi i have a string like "22/5/2006 12:00:00 pµ" and i want to create
a string like "05/22/06"
could someone please


Jun 5 '06 #7
I think that you have to be even more specific. Try to explain what it
is that you are trying to accomplish, rather then how you think that it
should be done.

tolisss wrote:
let me be a little more specific then i have this proerpty called
formatstring and a user can put in design mode any format string he
wants and the type representation.

but code doesn't know the type so to use the appropriate method

does that make any sense to u? how to procceed
Ο/Η Göran Andersson *γραψε:
If you wan't to parse any data type, then you have to be a bit more
specific about what kind of data you can expect, and how that should be
interpreted.

tolisss wrote:
supose i want a more generic method
suppose i do not know what type the format string is going to produce
is there a more generic format method? can;t use DateTime.Parse method
i want somethong like Type.Parse

Ο/Η Claes Bergefall *γραψε:
Take a look at DateTime.Parse and DateTime.ParseExact. Once you have a valid
DateTime object you can use its ToString method to format the output

/claes

"tolisss" <ap****************@gmail.com> wrote in message
news:11**********************@f6g2000cwb.googlegro ups.com...
Hi i have a string like "22/5/2006 12:00:00 pµ" and i want to create
a string like "05/22/06"
could someone please

Jun 6 '06 #8

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
6483
by: Alpha | last post by:
Hi, I'm maintaining C# code and am fairly new with C# programming. I'm looking for codes that's droping the 2nd digit of a nuber printed out and I suspect it's the code below. Can someone tell me...
11
2102
by: Matt | last post by:
string format formula to write a text file below is not working for me pos 1 to 10 name pos 15 to 30 lastname pos 45 to 75 job Adam smith programmer string fmt = "{1,10}{15-30}{45,75}"...
38
807
by: nobody | last post by:
I know that given a FormatString and a DateTime you can use DateTime.ToString(...) to convert the DateTime to a String. My question is how can you turn that around? Given a String and a...
4
2842
by: Chris Dunaway | last post by:
I have a table in the database with a phone number field. The phone number is stored without any punctuation (e. g. 9995551234). I wish to take that string and format it for display (e. g. (999)...
3
1405
by: scorpion53061 | last post by:
I have little hope of resolving this as I have had to contact outside help. But I thought I would post it here to see if anyone could add an idea or solution. 1. I have a form in a Class...
5
2305
by: AMP | last post by:
Hello, I want to add some variables to a string and this isnt working. textBox1.Text="'BSL version='+ bslVerHi+ bslVerLo"; What am I doing wrong? Thanks Mike
8
4980
by: Lucky | last post by:
hi guys! back again with another query. the problem is like this. i want to print a line like this: "---------------------------------------------" the easiest way is to simply assign it to...
3
1872
by: shawrie | last post by:
Hello everyone can anyone please help me? I basically want to set the length of a string variable to help spacing my simple report out. i tried dim test as string(14) but it didnt like that
8
2201
by: Armando Rocha | last post by:
Hi, Hi have a string with 16 chars "25DD68EDEB8D5E11" and i want show it in form like this "25DD-68ED-EB8D-5E11", i try String.Format("{0:####-####-####-####}", mystr), but not work, i think...
3
3246
by: 6afraidbecause789 | last post by:
If able, can someone please help make a Where clause that strings together IDs in a multi-select listbox AND includes a date range. I wasnt thinking when I used the code below that strings...
0
7259
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7158
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7380
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
7098
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7523
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
3232
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3221
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1592
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
455
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.