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. Visual Basic
  4. Convert string to date?? Help???

Convert string to date?? Help???

Scheduled Pinned Locked Moved Visual Basic
helpquestion
5 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.
  • N Offline
    N Offline
    Nathan Buckley
    wrote on last edited by
    #1

    Hi everyone, I am trying to convert a string format date e.g "13/07/2006" to a date. I am getting an error "String was not recognized as a valid DateTime". How can i convert it to "MM/dd/yyyy" format. Please reply thanks, Sanded

    G P B 3 Replies Last reply
    0
    • N Nathan Buckley

      Hi everyone, I am trying to convert a string format date e.g "13/07/2006" to a date. I am getting an error "String was not recognized as a valid DateTime". How can i convert it to "MM/dd/yyyy" format. Please reply thanks, Sanded

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Use the DateTime.ParseExact method. --- b { font-weight: normal; }

      1 Reply Last reply
      0
      • N Nathan Buckley

        Hi everyone, I am trying to convert a string format date e.g "13/07/2006" to a date. I am getting an error "String was not recognized as a valid DateTime". How can i convert it to "MM/dd/yyyy" format. Please reply thanks, Sanded

        P Offline
        P Offline
        paragyerawar
        wrote on last edited by
        #3

        :cool:hey u can use any of this... 1.FormatDateTime(frDate, DateFormat.ShortDate) 2.cDate(frdate) this is best method to convert ur string . Parag

        1 Reply Last reply
        0
        • N Nathan Buckley

          Hi everyone, I am trying to convert a string format date e.g "13/07/2006" to a date. I am getting an error "String was not recognized as a valid DateTime". How can i convert it to "MM/dd/yyyy" format. Please reply thanks, Sanded

          B Offline
          B Offline
          bMILAN Cybage
          wrote on last edited by
          #4

          first import System.Globalization namespace 'create an object of culture info Dim myCI As New CultureInfo("en-US", False) 'take culture info's clone Dim myCIclone As CultureInfo = CType(myCI.Clone(), CultureInfo) 'customise its date pattern myCIclone.DateTimeFormat.DateSeparator = "/" myCIclone.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy" 'parse date string with this pattern DateTimePicker1.Value = DateTime.Parse("13/07/2006", myCIclone.DateTimeFormat) and u have done !;) milan

          N 1 Reply Last reply
          0
          • B bMILAN Cybage

            first import System.Globalization namespace 'create an object of culture info Dim myCI As New CultureInfo("en-US", False) 'take culture info's clone Dim myCIclone As CultureInfo = CType(myCI.Clone(), CultureInfo) 'customise its date pattern myCIclone.DateTimeFormat.DateSeparator = "/" myCIclone.DateTimeFormat.ShortDatePattern = "dd/MM/yyyy" 'parse date string with this pattern DateTimePicker1.Value = DateTime.Parse("13/07/2006", myCIclone.DateTimeFormat) and u have done !;) milan

            N Offline
            N Offline
            Nathan Buckley
            wrote on last edited by
            #5

            thanks milanatdigi, Your solution was helpful. While the Solution provided by other guys created the same error message but i really appreciate their help as well. thanks, Sanded

            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