CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2000
    Location
    India, Tamilnadu
    Posts
    279

    When I convert '12/3/2003' using COleDateTime::ParseDateTime, takes 12 as date. Why?

    My regional setting is australia.
    I have a string '12/3/2003' (mm/dd/yy) in US format to be parsed as COleDateTime.
    When I convert using COleDateTime::ParseDateTime, it considers 12 as date and 3 as month.
    I know this is because of my regional setting.
    How to make ParseDateTime to consider the string as US date string?


    Code:
    CString sTimeString = "12/3/2003";	// 12 th month
    	
    COleDateTime oleTime;
    oleTime.ParseDateTime(sTimeString,LOCALE_NOUSEROVERRIDE);  // I tried this
    //oleTime.ParseDateTime(sTimeString,0 );	// I tried this also.
    
    AfxMessageBox(oleTime.Format("%m/%d/%y"));	// the month 12 th becomes date
    Displays 3/12/2003
    How to instruct ParseDateTime to consider the string in US format ?

    Thanks a lot for your helps
    Anita Eugene

  2. #2
    Join Date
    Jan 2000
    Location
    India, Tamilnadu
    Posts
    279

    Any solution based on Ctime ?

    Even a solution based on CTime will help.

    Thanks
    Anita Eugene

  3. #3
    Join Date
    May 2002
    Posts
    1,435
    oleTime.ParseDateTime(_T("12/2/2003"),0,MAKELANGID(LANG_ENGLISH,SUBLANG_ENGLISH_US));

  4. #4
    Join Date
    Jan 2000
    Location
    India, Tamilnadu
    Posts
    279

    Great !!!!

    Thanks a lot.
    Anita Eugene

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