469,314 Members | 2,237 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,314 developers. It's quick & easy.

How to convert user-defined custom format date string to date value

I write an application which can let user define own date format to input,
How to convert the date string to date value with end-user defined date
format?

Example, User Defined Date Format as "dd/MM/yyyy"

input as "01082003" convert to date value as, 01 Aug 2003

Example, User Defined Date Format as "yyyy,dd,MM"

input as "2004,03,30" convert to date value as, 30 Mar 2004

Example, User Defined Date Format as "MM dd yyyy"

input as "05 07 2005" convert to date value as, 07 May 2005

Assumption: I cannot change regional language settings, because some PCs may
also use by several users whom have use own faviour date format.
Nov 21 '05 #1
1 4333
Hi,

This should work:

~
DateTime.ParseExact(InputString, UserDefinedFormat,
Globalization.DateTimeFormatInfo.InvariantInfo)
~

HTH

Roman

Nov 21 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Closer | last post: by
1 post views Thread by Logan X via .NET 247 | last post: by
10 posts views Thread by | last post: by
22 posts views Thread by ACaunter | last post: by
2 posts views Thread by egoldthwait | last post: by
2 posts views Thread by Jim Andersen | last post: by
23 posts views Thread by Carl K | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
reply views Thread by harlem98 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.