Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C#
  4. Date Conversion

Date Conversion

Scheduled Pinned Locked Moved C#
tutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    Parvai
    wrote on last edited by
    #1

    How to convert 070818 to 20070818? any one provide solution for me

    parthiban

    C L P 3 Replies Last reply
    0
    • P Parvai

      How to convert 070818 to 20070818? any one provide solution for me

      parthiban

      C Offline
      C Offline
      Christian Graus
      wrote on last edited by
      #2

      add 20 to the front of it ? Your question isn't making much sense, I'm afraid. Do you have this as a number, or a string ? what's the hard bit, are you assuming all dates are in the past, or not ?

      Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

      1 Reply Last reply
      0
      • P Parvai

        How to convert 070818 to 20070818? any one provide solution for me

        parthiban

        L Offline
        L Offline
        Luc Pattyn
        wrote on last edited by
        #3

        You can use DateTime.Parse or DateTime.ParseExact, and DateTime.ToString methods and apply a "Custom DateTime Format String" the format specifiers "y", "yy" and "yyyy" need your attention; look it up on MSDN :)

        Luc Pattyn [Forum Guidelines] [My Articles]


        this weeks tips: - make Visual display line numbers: Tools/Options/TextEditor/... - show exceptions with ToString() to see all information - before you ask a question here, search CodeProject, then Google


        1 Reply Last reply
        0
        • P Parvai

          How to convert 070818 to 20070818? any one provide solution for me

          parthiban

          P Offline
          P Offline
          PIEBALDconsult
          wrote on last edited by
          #4

          I have that same problem, a log from a third party program begins each line with YYMMDD, so my reader class has private static readonly string Century = ( System.DateTime.Now.Year / 100 ).ToString() ; then when I read in a line from the log, I do date = Century + line.Substring ( 0 , 6 ) ;

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups