CodeGuru Forums -
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic Newsletters VB Forums Developer.com


Newest CodeGuru.com Articles:

  • Installing SQL Server 2008
  • Writing UDFs for Firebird Embedded SQL Server
  • [Updated] Shutdown Manager
  • Building Windows Azure Cloud Service Applications with Azure Storage and the Azure SDK

  • Search CodeGuru:
     



    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Managed C++ and C++/CLI
    FAQ Members List Calendar Search Today's Posts Mark Forums Read

    Managed C++ and C++/CLI Discuss Managed C++ and .NET-specific questions related to C++.

    Reply
     
    Thread Tools Search this Thread Rate Thread Display Modes
      #1    
    Old July 18th, 2005, 10:33 AM
    rm_kapadia rm_kapadia is offline
    Junior Member
     
    Join Date: Dec 2004
    Location: India
    Posts: 11
    rm_kapadia is an unknown quantity at this point (<10)
    Smile Custom String DateFormating in VC++.Net

    Hi All,

    I'm using vc++.net and have a string that represents a date.

    "122804"(mmddyy)

    Any ideas on using DateTimeFormatInfo to take that value and make it: ( or How to write a Custom parser class for this numeric Data )

    "20041228" (yyyymmdd)

    or if not possible:

    "041228"(yymmdd)

    Any help would be great.

    Thanks in Advance ...

    Rajan Kapadia
    Reply With Quote
      #2    
    Old July 18th, 2005, 11:13 AM
    GCDEF GCDEF is offline
    Elite Member
    Power Poster
     
    Join Date: Nov 2003
    Posts: 7,853
    GCDEF has a brilliant future (2000+)GCDEF has a brilliant future (2000+)GCDEF has a brilliant future (2000+)GCDEF has a brilliant future (2000+)GCDEF has a brilliant future (2000+)GCDEF has a brilliant future (2000+)GCDEF has a brilliant future (2000+)GCDEF has a brilliant future (2000+)GCDEF has a brilliant future (2000+)GCDEF has a brilliant future (2000+)GCDEF has a brilliant future (2000+)
    Re: Custom String DateFormating in VC++.Net

    You could do it with CStrings.

    Code:
    CString strMDY = "122804";
    CString strYMD;
    strYMD.Format("20%s%s", strMDY.Right(2),  strMDY.Left(4));
    Reply With Quote
      #3    
    Old July 19th, 2005, 02:00 AM
    rm_kapadia rm_kapadia is offline
    Junior Member
     
    Join Date: Dec 2004
    Location: India
    Posts: 11
    rm_kapadia is an unknown quantity at this point (<10)
    Lightbulb Re: Custom String DateFormating in VC++.Net

    Thanks for u r Reply .....
    But at Runtime I only know what is come as a text for my Date!!!

    various possibility are :

    mmddyyyy

    mdyyyy
    mmdyyyy
    mddyyyy

    mmdy
    mddy
    mdyy

    mddyy
    mmdyy
    mmddy

    mmddyy

    mdy
    mmd
    ddm

    I m Confused due to ambiguation for this text( here ... Numerics) comes as a 6,5,4,3 digits .... (i.e.: for 5digits --> mddyy,mmdyy,mmddyy) how to handle these situations ....... I m to'much Confuseed !......!

    can any one help me for this soluation??

    thanks in advance!!

    Rajan Kapadia
    Reply With Quote
      #4    
    Old July 19th, 2005, 05:41 AM
    Andy Tacker Andy Tacker is offline
    More than "Just Another Member"
     
    Join Date: Jun 2001
    Location: 55°50' N 37°39' E
    Posts: 1,503
    Andy Tacker  is a jewel in the rough (300+)Andy Tacker  is a jewel in the rough (300+)Andy Tacker  is a jewel in the rough (300+)Andy Tacker  is a jewel in the rough (300+)
    Re: Custom String DateFormating in VC++.Net

    moved to VC.NET forum.


    Datatime class has function ToString()... where you can specify the format you want to see...

    Dateime.Now.ToString("yyyy-MM-dd HH:mm:ss")
    __________________
    If you think you CAN, you can, If you think you CAN'T, you are probably right.

    Have some nice Idea to share? Write an Article Online or Email to us and You may WIN a Technical Book from CG.
    Reply With Quote
      #5    
    Old July 19th, 2005, 08:27 AM
    rm_kapadia rm_kapadia is offline
    Junior Member
     
    Join Date: Dec 2004
    Location: India
    Posts: 11
    rm_kapadia is an unknown quantity at this point (<10)
    Lightbulb Re: Custom String DateFormating in VC++.Net

    Quote:
    Originally Posted by Andy Tacker
    moved to VC.NET forum.


    Datatime class has function ToString()... where you can specify the format you want to see...

    Dateime.Now.ToString("yyyy-MM-dd HH:mm:ss")

    Thanks for reply... but ,, I have mantion clearly how I can Dis-ambiguates between possiblty of the same string divde in to same but diffrent parts....
    i.e: for 5digits --> mddyy,mmdyy,mmddyy How to handle this ???

    other Varios possibility are :
    mmddyyyy ( 8 digit max)

    mdyyyy
    mmdyyyy
    mddyyyy

    mmdy
    mddy
    mdyy

    mddyy
    mmdyy
    mmddy

    mmddyy

    mdy
    mmd
    ddm ( 3 digit min)

    I m Confused due to ambiguation for this text( here ... Numerics) comes as a 6,5,4,3 digits .... (i.e.: for 5digits --> mddyy,mmdyy,mmddyy) how to handle these situations ....... I m to'much Confuseed !......!
    Reply With Quote
    Reply

    Bookmarks
    Go Back   CodeGuru Forums > Visual C++ & C++ Programming > Managed C++ and C++/CLI


    Thread Tools Search this Thread
    Search this Thread:

    Advanced Search
    Display Modes Rate This Thread
    Rate This Thread:

    Posting Rules
    You may not post new threads
    You may not post replies
    You may not post attachments
    You may not edit your posts

    BB code is On
    Smilies are On
    [IMG] code is On
    HTML code is Off
    Forum Jump


    All times are GMT -5. The time now is 06:52 AM.



    Acceptable Use Policy

    internet.comMediabistrojusttechjobs.comGraphics.com

    WebMediaBrands Corporate Info


    Advertise | Newsletters | Feedback | Submit News

    Legal Notices | Licensing | Permissions | Privacy Policy


    Powered by vBulletin® Version 3.7.3
    Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
    Copyright WebMediaBrands Inc. 2002-2009