Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8633735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T09:32:33+00:00 2026-06-12T09:32:33+00:00

Why does CDate and parseExact turn today’s date (3rd October), represented as 03/10/2012, into

  • 0

Why does CDate and parseExact turn today’s date (3rd October), represented as 03/10/2012, into 10/03/2012? I am using Windows 7, VS2012. All my settings in Control Panel are UK/GB. I have tried adding the lines

    System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-GB", True)
    System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("en-GB", True)

with no effect.

Here is my code – you will see that I have to resort to swapping the day and month of the text version in order to get the date I want

    dim txtDate As String = "03/10/2012"
    Dim strOriginalDate As String = txtDate   ' 03/10/2012
    Dim dtmdate1 As Date = CDate(txtDate)     ' #10/03/2012#
    Dim dtmdate2 As Date = DateTime.ParseExact(txtDate, "dd/MM/yyyy", Nothing) ' #10/03/2012#
    txtDate = Split(txtDate, "/")(1) & "/" & Split(txtDate, "/")(0) & "/" & Split(txtDate, "/")(2)
    Dim dtmdate3 As Date = CDate(txtDate)     ' #3/10/2012#
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T09:32:34+00:00Added an answer on June 12, 2026 at 9:32 am

    I suspect that you are looking at the date values in the Locals pane of the debugger. If you actually write out the values you will find they are as required:

    Module Module1
    
        Sub Main()
            System.Threading.Thread.CurrentThread.CurrentCulture = New System.Globalization.CultureInfo("en-GB", True)
            System.Threading.Thread.CurrentThread.CurrentUICulture = New System.Globalization.CultureInfo("en-GB", True)
    
            Dim txtDate As String = "03/10/2012"
            Dim strOriginalDate As String = txtDate
            Dim dtmdate1 As Date = CDate(txtDate)
            Console.WriteLine(dtmdate1.ToString("dd MMM yyyy"))
    
            Dim dtmdate2 As Date = DateTime.ParseExact(txtDate, "dd/MM/yyyy", Nothing) ' #10/03/2012#
            Console.WriteLine(dtmdate2.ToString("dd MMM yyyy"))
            txtDate = Split(txtDate, "/")(1) & "/" & Split(txtDate, "/")(0) & "/" & Split(txtDate, "/")(2)
    
            Dim dtmdate3 As Date = CDate(txtDate)
            Console.WriteLine(dtmdate3.ToString("dd MMM yyyy"))
    
            Console.ReadLine()
    
        End Sub
    
    End Module
    

    The final line of output is, of course, not as desired because you have swapped the month and day.

    Tested with VS2012 RC on W7 x64 set to en-GB. You might want to test with setting VS’s locale: http://msdn.microsoft.com/en-US/library/9cytz106%28v=vs.80%29.aspx

    The display of the date as a date literal is entirely consistent with how a data literal is defined, for example see the Format Requirements subsection of Date Data Type (Visual Basic)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to convert a text field into a date using CDate() in a
Does anyone know of a free tool, similar to what is built into Visual
Does anybody know why this function, when passed an invalid date (e.g. timestamp) to
I'm using YUI 2's calendar in YUI 3. How does it load Sam's skin
Does anyone know of a way that I can insert the current date &
Here I am using XmlPullParser to parse the document below. It does not work
I am trying to enter a date in oracle database using to_date in preparedStatement
Does anyone know if there is a way to generate different code in the
Does COUNT(*) have any significant impact for MySQL performance if query already has GROUP
Does anyone have a translate function for x/y positions after rotation in javascript? for

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.