473,671 Members | 2,504 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 1775
Take a look at DateTime.Parse and DateTime.ParseE xact. 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.goog legroups.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(MyTim e.ToString("HH: mm:ss"));

Alain
"tolisss" <ap************ ****@gmail.com> a crit dans le message de news:
11************* *********@f6g20 00...legro 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 #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.goog legroups.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.ParseE xact. 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.goog legroups.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.ParseE xact. 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.goog legroups.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.ParseE xact. 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.goog legroups.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.ParseE xact. 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.goog legroups.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
6490
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 where I can look up explaination on the String.Format, the format string part like "("{0:.#0}". What's the trailing 0 and what is that "0:" means? I assume the "#" is the place holder character for th value obtain after the comma in the code. ...
11
2117
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}" // is not working any help ?
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 FormatString, how can you convert the String back to a DateTime? DateTime.Parse(...) doesn't use the FormatString. Now admitedly, if the format string is just "MM", it can't be done. But if the format string is "yyyyMMdd", or "ddMMMyyyy hhmmsst", it...
4
2849
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) 555-1234). I know that I can use the .substring method of the string class to get the characters I want and format it: Dim s As String With strPhone
3
1412
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 Control library along with 6 other namespaces. My root functions are in this form and all the other namespaces revolve around this form. I add the project as a dll to another windows project and call its functions there. Option Strict is
5
2315
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
4990
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 string and print it. but i want to use the String.Format() method if possible to do it.
3
1876
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
2219
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 that it is because the "mystr" it is already a string. Anyone can help me? Sorry my english....
3
3260
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 together the IDs of Clients from a multi-select listbox in an unbound text field, txtCriteria, on a form that is used to pick different reports. It appears that I now have so many clients that Ive reached the 255 character limit in the txtCriteria...
0
8483
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, well explore What is ONU, What Is Router, ONU & Routers main usage, and What is the difference between ONU and Router. Lets take a closer look ! Part I. Meaning of...
0
8402
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8927
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8825
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8605
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6237
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupr who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4227
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2819
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 we have to send another system
2
1816
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.