string to date conversion..please help..

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jupi13
    New Member
    • Jul 2008
    • 18

    string to date conversion..please help..

    i have this code..i don't know what where is the error in this one..it says data type mismatch.....

    Dim Mydate As Date
    Dim MydateString As String

    MydateString = "Text1.Text "
    Mydate = CDate(MydateStr ing) ''it is highlighted in this line..
    txtActCode = Mydate

    i don't know what's wrong with this one..
    any help would be much appreciated..
    thank you..
  • debasisdas
    Recognized Expert Expert
    • Dec 2006
    • 8119

    #2
    CDate Returns Results in System's Short Date Format.

    The parameter for cdate is any valid date expression as string.

    What are you passing ?

    Comment

    • jupi13
      New Member
      • Jul 2008
      • 18

      #3
      i have a textbox where i could input a date..example: October 2,2009.
      is "October 2,2009" a valid date expression string?

      Comment

      • jupi13
        New Member
        • Jul 2008
        • 18

        #4
        please help..it's really important.. have problems with comparing my dates

        i got a problem with regards to comparing my date from my textbox from the dates in my database... it says "Data type mismatch in criteria expression"

        i got my code here:


        txtActCode.Text = Format$(txtDate .Text, "MM/dd/YY")

        If rs.State = adStateOpen Then Set rs = Nothing
        rs.Open "SELECT * from tblActMeetings where fldActDate='" & txtActCode.Text & "'", cn

        the error is right in the underlined line of code...
        please help...
        would be much appreciated.... .

        Comment

        • debasisdas
          Recognized Expert Expert
          • Dec 2006
          • 8119

          #5
          Pass parameters to cdate in any of the following formats

          Statement Result
          =============== =============== ==
          CDate("May 14 1977") ------ 14/05/1977
          CDate("14/May/1977") ------ 14/05/1977
          CDate("14/05/1977") -------14/05/1977
          CDate("05/14/1977") -------14/05/1977

          Comment

          Working...