Hello,
I was wondering if there is an easy way to determine the date format of a string with a date.
"19-03-1983" to "dd-MM-yyyy"
"19-03-1983" to "dd-MM-yy"
Is there a function that supports this or do I have to write such a function myself?
Printable View
Hello,
I was wondering if there is an easy way to determine the date format of a string with a date.
"19-03-1983" to "dd-MM-yyyy"
"19-03-1983" to "dd-MM-yy"
Is there a function that supports this or do I have to write such a function myself?
As far as I know, you can parse it into a DateTime and then act on it, but if you need to determine what the original format was, you'd have to code it.
It cannot be determinet, it can be just estimated. Imagine date 1-2-2010. Is it the first february, or the second january? How could you decide it? Data formats must be agreed prior to working with them.
Take a look at System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat