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. Date Conversion Problem

Date Conversion Problem

Scheduled Pinned Locked Moved ASP.NET
5 Posts 3 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.
  • S Offline
    S Offline
    specialdreamsin
    wrote on last edited by
    #1

    Hi, Public MasterDispDt As String Public Sub ExFunction() MasterDispDt = DtlsDs.Tables("DtlsTab").Rows(r).Item("DispDate").ToString End Sub TxtDispDate is a Textbox, Calender Selected value assigned to it. Dim TDate As Date = CDate(Trim(txtDespDate.Text)) Dim MDate As Date = CDate(Trim(MasterDispDt)) If TDate < MDate Then 'Some Code Endif TxtDispDate I selected as '28-04-2009' The above Code giving Error : Error : Conversion from string "28-04-2009" to type 'Date' is not valid. Pl. Help me out Ramesh Sambari

    D H 2 Replies Last reply
    0
    • S specialdreamsin

      Hi, Public MasterDispDt As String Public Sub ExFunction() MasterDispDt = DtlsDs.Tables("DtlsTab").Rows(r).Item("DispDate").ToString End Sub TxtDispDate is a Textbox, Calender Selected value assigned to it. Dim TDate As Date = CDate(Trim(txtDespDate.Text)) Dim MDate As Date = CDate(Trim(MasterDispDt)) If TDate < MDate Then 'Some Code Endif TxtDispDate I selected as '28-04-2009' The above Code giving Error : Error : Conversion from string "28-04-2009" to type 'Date' is not valid. Pl. Help me out Ramesh Sambari

      D Offline
      D Offline
      Dev S
      wrote on last edited by
      #2

      this problem can be beacuase of date format. try other formats like "MM/dd/yyyy" and apply break and check the result.

      S 1 Reply Last reply
      0
      • D Dev S

        this problem can be beacuase of date format. try other formats like "MM/dd/yyyy" and apply break and check the result.

        S Offline
        S Offline
        specialdreamsin
        wrote on last edited by
        #3

        Hi, When I run from Source Code, there is no problem. it is working fine. Even i run without debugging, that time also its fine. When I publish it to a folder and open , then the problem is coming. Ramesh Sambari

        D 1 Reply Last reply
        0
        • S specialdreamsin

          Hi, When I run from Source Code, there is no problem. it is working fine. Even i run without debugging, that time also its fine. When I publish it to a folder and open , then the problem is coming. Ramesh Sambari

          D Offline
          D Offline
          Dev S
          wrote on last edited by
          #4

          While u r converting it to date format just specify the format like it is shortdate string or whatever u like, to all date controls and variable.

          1 Reply Last reply
          0
          • S specialdreamsin

            Hi, Public MasterDispDt As String Public Sub ExFunction() MasterDispDt = DtlsDs.Tables("DtlsTab").Rows(r).Item("DispDate").ToString End Sub TxtDispDate is a Textbox, Calender Selected value assigned to it. Dim TDate As Date = CDate(Trim(txtDespDate.Text)) Dim MDate As Date = CDate(Trim(MasterDispDt)) If TDate < MDate Then 'Some Code Endif TxtDispDate I selected as '28-04-2009' The above Code giving Error : Error : Conversion from string "28-04-2009" to type 'Date' is not valid. Pl. Help me out Ramesh Sambari

            H Offline
            H Offline
            Hajab
            wrote on last edited by
            #5

            To convert a string to date, the date format should be MM/DD/YYYY OR MM/DD/YY. The date "28-04-2009" is in the format dd-mm-yyyy. This is the reason for the error. Convert the string to correct format and your will get the result.

            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