Converting String to Text

Mcgrco

Registered User.
Local time
Today, 13:34
Joined
Jun 19, 2001
Messages
118
I want to update a fiel in a table with a derived reporting date ie "25/06/2002". The value is text so im trying to convert it to a date . the fiel i end up with looks like 00:04:28. My code is
can anyone show me where im going wrong

strRepdate = Mid(ImportDate, 1, 2) & "/" & Mid(ImportDate, 3, 2) & "/" & "20" & Mid(ImportDate, 5, 2)

Repdate = CVDate(strRepdate)

sSql1 = sSql1 & ""
sSql1 = sSql1 & " UPDATE [" & ImportTable & "]"
sSql1 = sSql1 & " SET [" & ImportTable & "].ReportingDate=" & Repdate & ";" '
db.Execute (sSql1)

sSql1 = ""
 
sorry it should have read Converting String to a Date

sorry it should have read Converting String to a Date
 
Mcgrco

Try this:

Repdate = CDate(your_string)

Make sure you declare Repdate as Date... Good luck.

Anton
 
Use DateSerial rather than CVDate to avoid variations in the Regional Settings on a Workstation.

Also, include # on both sides of your date in the SQL statement.

HTH,
 

Users who are viewing this thread

Back
Top Bottom