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. Web Development
  3. ASP.NET
  4. String to Date

String to Date

Scheduled Pinned Locked Moved ASP.NET
csharpasp-nethelptutorial
6 Posts 5 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.
  • K Offline
    K Offline
    Khan Bangash
    wrote on last edited by
    #1

    How to Change String to Date. I use the following but there was error. startDate = ctype(txtDate.Text,Date) also i tried startDate = cDate(txtDate.Text) Both gives error. I use ASP.NET with VB.NET Thanks in Advance.

    M L 2 Replies Last reply
    0
    • K Khan Bangash

      How to Change String to Date. I use the following but there was error. startDate = ctype(txtDate.Text,Date) also i tried startDate = cDate(txtDate.Text) Both gives error. I use ASP.NET with VB.NET Thanks in Advance.

      M Offline
      M Offline
      mareers
      wrote on last edited by
      #2

      it depends on the date format u accept from the user... i mean....what is the string u get from the user in txtDate.Text?? if it is of type say....July 24, 1983 then cDate(txtDate.Text) works fine.... check it out.....

      mareers

      K 1 Reply Last reply
      0
      • M mareers

        it depends on the date format u accept from the user... i mean....what is the string u get from the user in txtDate.Text?? if it is of type say....July 24, 1983 then cDate(txtDate.Text) works fine.... check it out.....

        mareers

        K Offline
        K Offline
        Khan Bangash
        wrote on last edited by
        #3

        I get Dat in dd/MM/yyyy format i-e 25/02/2007

        S 1 Reply Last reply
        0
        • K Khan Bangash

          I get Dat in dd/MM/yyyy format i-e 25/02/2007

          S Offline
          S Offline
          Spunky Coder
          wrote on last edited by
          #4

          Try System.DateTime.Parse(string s) for the format u have.

          Koushik

          S 1 Reply Last reply
          0
          • S Spunky Coder

            Try System.DateTime.Parse(string s) for the format u have.

            Koushik

            S Offline
            S Offline
            Sandeep Kumar
            wrote on last edited by
            #5

            Hiii, System.DateTime.Parse(string s), this going to work only if the input string format is "MM/dd/yyyy" so try to convert the input string to "MM/dd/yyyy"

            1 Reply Last reply
            0
            • K Khan Bangash

              How to Change String to Date. I use the following but there was error. startDate = ctype(txtDate.Text,Date) also i tried startDate = cDate(txtDate.Text) Both gives error. I use ASP.NET with VB.NET Thanks in Advance.

              L Offline
              L Offline
              linpihong
              wrote on last edited by
              #6

              or you can use DateTime dt = new DateTime(Year, Month, Day), you must convert the txtDate.Text to three string first

              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