By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
428,659 Members | 940 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 428,659 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.