471,355 Members | 1,694 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,355 software developers and data experts.

Date Conversion

I have a string variable "1/2/2007". What is the easiest way to convert it
to "20070102". In VB6, I could cat it to to date and format. Is there equiv
C# code to do that. I don't want to do any string manuipulation.
Thanks
Sep 14 '07 #1
3 1538
Phil,

The Class Library should be the exact same in C# as in VB6 (they are
both using the same assemblies).

DateTime.Parse("1/2/2007").ToString("yyyMMdd")

-James

Sep 14 '07 #2
Thanks James. Perfect.
"james" <ja********@gmail.comwrote in message
news:11**********************@50g2000hsm.googlegro ups.com...
Phil,

The Class Library should be the exact same in C# as in VB6 (they are
both using the same assemblies).

DateTime.Parse("1/2/2007").ToString("yyyMMdd")

-James

Sep 14 '07 #3
One little addition, when using the
convert.todatetime(string) = can enter ISO Date format as well as the
default for the location.

ISO = YYYY/MM/DD; for america MM/DD/YYYY; and most others :) DD/MM/YYYY
Sep 15 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

3 posts views Thread by praba kar | last post: by
1 post views Thread by Riley DeWiley | last post: by
1 post views Thread by Franck | last post: by
10 posts views Thread by melissa.nava | last post: by
8 posts views Thread by no_spam_for_gman | last post: by
10 posts views Thread by =?Utf-8?B?TWlrZQ==?= | last post: by
2 posts views Thread by RN1 | last post: by
reply views Thread by XIAOLAOHU | last post: by

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.