Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Update DateTime field from string

Status
Not open for further replies.

BlindPete

Programmer
Jul 5, 2000
711
US
Hello,

I am using ASP classic with an access dbase and I'm having trouble writing and UPDATE query for the DateTime field.

I have a varchar field with information like this:
"dob 01/01/2009" I want to update another field that is actually a datetime field. but I can't figure out how.

I've tried many variations of below:

UPDATE tblPet SET dateOfBirth = CDATE(MID(AGE,4,100)) WHERE LEFT(LCASE(AGE), 3)='dob'

Any ideas?

-Pete
 
You might
Code:
UPDATE tblPet SET dateOfBirth = CDATE([red]Trim$([/red]MID(AGE,4)[red])[/red]) WHERE LEFT(LCASE(AGE), 3)='dob'
But it should work the way you have it.

What results are you getting when you run it?
 
LOL naturally I agree, it should work. ;-) The ASP server uses a MS Jet ODBC connection.
Code:
Error Type:
Microsoft JET Database Engine (0x80040E07)
Data type mismatch in criteria expression.

I'll try your method here shortly.

-Pete
 
Bummer, same error. This is one off maintenance query. I guess just dlaod the dbase and execute the update in the Access environment on local host.

I suspect that the are conversion errors on the string field, that are canceling the entire transaction.

I guess I could break into 2, identify the records, update 1 by 1 and find the offenders.

-Pete
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top