convert text field to date field

G

Guest

I have a table with a text field that represents a persons birthday. It shows
for example 11231970. I would like to convert this field to a true date
field which would read 11/23/1970 so I can calculate age of students.
 
M

Mike Labosh

Check out the DateSerial and the Left$(), Mid$() and Right$() functions.

Presuming you have a table called YourTable that has your existing
StringColumn and a new DateColumn, you could run this query, and then open
the table in design view and delete the StringColumn:

UPDATE YourTable
SET DateColumn = DateSerial(
Right$(StringColumn, 4),
Mid$(StringColumn, 3, 2),
Left$(StringColumn, 2)
)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top