Connecting Tech Pros Worldwide Help | Site Map

string to date conversion..please help..

Newbie
 
Join Date: Jul 2008
Posts: 16
#1: Oct 3 '09
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(MydateString) ''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's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,497
#2: Oct 3 '09

re: string to date conversion..please help..


CDate Returns Results in System's Short Date Format.

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

What are you passing ?
Newbie
 
Join Date: Jul 2008
Posts: 16
#3: Oct 3 '09

re: string to date conversion..please help..


i have a textbox where i could input a date..example: October 2,2009.
is "October 2,2009" a valid date expression string?
Newbie
 
Join Date: Jul 2008
Posts: 16
#4: Oct 4 '09

re: string to date conversion..please help..


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.....
debasisdas's Avatar
Moderator
 
Join Date: Dec 2006
Location: Bangalore ,India
Posts: 7,497
#5: Oct 5 '09

re: string to date conversion..please help..


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
Reply