CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Apr 2010
    Posts
    1

    Determine the format a 'date' string

    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?

  2. #2
    Join Date
    Apr 2010
    Posts
    131

    Re: Determine the format a 'date' string

    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.

  3. #3
    Join Date
    Mar 2004
    Location
    Prague, Czech Republic, EU
    Posts
    1,701

    Re: Determine the format a 'date' string

    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.
    • Make it run.
    • Make it right.
    • Make it fast.

    Don't hesitate to rate my post.

  4. #4
    Join Date
    Sep 2008
    Location
    Netherlands
    Posts
    865

    Re: Determine the format a 'date' string

    Take a look at System.Threading.Thread.CurrentThread.CurrentCulture.DateTimeFormat

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured